skillfed

partial-json-parser

Parse partial JSON generated by LLM

partial-json-parser v0.2.1.1.post7 6.4M downloads/30d#1,920 on PyPI137
Permissive license MIT Active released

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-parser

uv

uv add partial-json-parser

poetry

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 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

Development Status :: 5 - Production/StableIntended Audience :: Developers

Tags

parse incomplete jsonllm streaming jsonpartial json parserjson from language modelsincomplete json handlingstream json parsingjson completion
llm-integrationjson-streaming

More Text Processing packages