--- id: partial-json-parser version: "0.2.1.1.post7" license: MIT license_treatment: permissive maintenance: active --- # partial-json-parser — Parse partial JSON generated by LLM License: permissive · Maintenance: active · Downloads: 6.4M/mo ## 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 above — 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 pip install partial-json-parser uv add partial-json-parser poetry add partial-json-parser ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 6.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags parse incomplete json, llm streaming json, partial json parser, json from language models, incomplete json handling, stream json parsing, json completion, llm-integration, json-streaming [View on SkillFed](https://skillfed.io/packages/partial-json-parser) · [View on PyPI](https://pypi.org/project/partial-json-parser/)