partial-json-parser
Parse partial JSON generated by LLM
What it is and what it does
partial-json-parser handles a specific problem in LLM integration: when streaming JSON responses token-by-token, the JSON is incomplete until the final token arrives, making standard JSON parsing fail. This library extracts and returns whatever valid data it can from incomplete JSON, and can also complete partial JSON strings to valid syntax so they parse cleanly.
The parser works like the standard json.loads when given complete JSON, but accepts an optional `allow_partial` parameter (bitwise flags from the `Allow` enum) to specify which data types are permitted to be incomplete—strings, numbers, arrays, objects, booleans, null, or special values like NaN and Infinity. By default it allows all partial types. It has zero runtime dependencies, is implemented in pure Python, and includes type hints.
Use it for:
- Stream structured data from LLM APIs (OpenAI, Anthropic, etc.) and display partial results to users as tokens arrive.
- Extract valid JSON objects from incomplete LLM responses mid-generation without waiting for completion.
- Build chat interfaces that show structured data (like JSON-formatted lists or tables) incrementally as the model generates them.
- Parse and validate JSON from sources that may truncate or cut off mid-response, recovering what data is available.
- Debug or inspect malformed JSON by attempting to extract the maximum valid structure before the error point.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses incomplete JSON strings generated by LLM streaming, extracting usable data before the full response arrives, and can complete partial JSON to valid syntax.
Yes. This is a specialized, well-maintained tool with zero dependencies, permissive licensing, and a clear use case in modern LLM-streaming workflows. The active maintenance, recent releases, and top-5000 PyPI position indicate real adoption. Install if you're building applications that stream structured JSON from language models.
Install
partial-json-parser on PyPI
pip
pip install partial-json-parseruv
uv add partial-json-parserpoetry
poetry add partial-json-parserInstalling partial-json-parser
Before you install
Zero runtime dependencies and pure Python implementation make installation frictionless. Active maintenance with recent releases; last commit 2026-04-22 and latest release 2025-11-17 indicate ongoing support.
License in practice
MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install partial-json-parser
from partial_json_parser import loads
result = loads('{"key": "v') # Returns: {'key': 'v'}
# Or complete the JSON string:
from partial_json_parser import ensure_json
completed = ensure_json('{"key": "v') # Returns: '{"key": "v"}'
Requires Python 3.6 or later.
Verify before relying
- Performance characteristics when parsing very large incomplete JSON structures.
- Behavior with deeply nested or complex partial JSON edge cases beyond the documented examples.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 270 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,367,402/month — #1,920 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: partial_json_parser-0.2.1.1.post7-py3-none-any.whl
Keywords: JSON, parser, LLM, nlp
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
json-repairParses and repairs malformed JSON strings from…
permissive · top 1,000 on PyPI
langdiffLangDiff streams structured LLM outputs to…
permissive · top 15,000 on PyPI
partialjsonParses incomplete or malformed JSON strings…
permissive · top 15,000 on PyPI
streamingjsonCompletes partial JSON strings into…
permissive · top 15,000 on PyPI
jiterA fast JSON parser that converts bytes into…
permissive · top 1,000 on PyPI
dirtyjsonParses JSON-like data from files containing…
permissive · top 5,000 on PyPI
fix-busted-jsonRepairs malformed JSON strings by fixing common…
permissive · top 15,000 on PyPI
instructorInstructor wraps LLM APIs to extract validated,…
permissive · top 5,000 on PyPI
prefixdateParses date strings with partial precision…
permissive · top 5,000 on PyPI