json-repair
A package to repair broken json strings
Decision gist · record as of 2026-08-14
Yes. The package solves a real problem with zero runtime dependencies, active maintenance, no known vulnerabilities, and a permissive MIT license. It is most valuable if you regularly consume JSON from LLMs, APIs, or user input where malformation is expected. If your JSON always comes from trusted, well-formed sources, the overhead is unnecessary—use standard json.loads() instead.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- No runtime dependencies and a pure Python wheel distribution make installation straightforward.
- The package is actively maintained with a recent release and no known vulnerabilities.
License · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
last release 2026-08-12 (2 days) · last repo commit 2026-08-12 · 5,071 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 38,109,958 downloads/mo, #716 on PyPI
Alternatives
Verify before relying
pip install json-repair
import json_repair
bad_json = '{"users":[{"name":"Ada","role":"admin",}],"ok":true'
decoded_object = json_repair.loads(bad_json)
# Returns: {'users': [{'name': 'Ada', 'role': 'admin'}], 'ok': True}- Extent of JSON corruption that the repair parser can successfully handle before returning empty string or raising an error.
- Performance characteristics when processing very large malformed JSON documents.
- Whether the repair heuristics preserve semantic intent in ambiguous cases (e.g., when multiple valid repairs are possible).
What it is and what it does
json-repair is a lightweight Python library that attempts to parse and fix malformed JSON strings that would normally fail standard JSON parsing. It handles common LLM output errors like missing quotes, trailing commas, unmatched brackets, and stray text by applying repair heuristics to restore valid JSON structure. The library works as a drop-in replacement for json.loads() and json.load(), automatically trying strict parsing first and falling back to repair logic only when needed.
The package is designed for scenarios where JSON comes from untrusted or imperfect sources—LLM responses, user input, log files, or API responses that may be truncated or malformed. It supports auto-completion of missing values with defaults, handles Python-style tuples, recognizes case-insensitive boolean and null values, and can preserve non-Latin characters when configured. For performance-critical paths where you know input is already invalid, it offers a skip_json_loads flag to bypass the initial validation step.
Use it for
- Parse JSON responses from large language models that occasionally omit closing brackets or add stray text.
- Recover structured data from incomplete API responses or truncated log entries without manual preprocessing.
- Handle user-submitted JSON that may contain syntax errors or non-standard formatting.
- Validate and repair JSON from external sources before passing to downstream processing.
- Fallback layer in applications that need to extract data even when input is partially corrupted.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package solves a real problem with zero runtime dependencies, active maintenance, no known vulnerabilities, and a permissive MIT license. It is most valuable if you regularly consume JSON from LLMs, APIs, or user input where malformation is expected. If your JSON always comes from trusted, well-formed sources, the overhead is unnecessary—use standard json.loads() instead.
Install
json-repair on PyPI
Before you install
No runtime dependencies and a pure Python wheel distribution make installation straightforward. The package is actively maintained with a recent release and no known vulnerabilities.
Requires Python 3.10 or later.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install json-repair
import json_repair
bad_json = '{"users":[{"name":"Ada","role":"admin",}],"ok":true'
decoded_object = json_repair.loads(bad_json)
# Returns: {'users': [{'name': 'Ada', 'role': 'admin'}], 'ok': True}
Verify before relying
- Extent of JSON corruption that the repair parser can successfully handle before returning empty string or raising an error.
- Performance characteristics when processing very large malformed JSON documents.
- Whether the repair heuristics preserve semantic intent in ambiguous cases (e.g., when multiple valid repairs are possible).
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 38,109,958 / month, #716 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Operating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: json_repair-0.63.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fix broken json”
- json-repairParses and repairs malformed JSON strings from LLMs, APIs, logs, and…
- fix-busted-jsonRepairs malformed JSON strings by fixing common syntax errors like…
- mkdocs-redirectsA MkDocs plugin that generates HTTP redirects for moved or renamed…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Repairs malformed JSON strings by fixing common syntax errors like unquoted keys, wrong quote types, missing commas, and Python literal values, then optionally extracts JSON objects from surrounding text.
Parses incomplete JSON strings generated by LLM streaming, extracting usable data before the full response arrives, and can complete partial JSON to valid syntax.
Parses and serializes JSON with support for single-line and block comments, plus trailing commas in arrays and objects.
Install it if you need to parse or generate JSON with comments.
Parses JSON with comments, multiline strings, and trailing commas by preprocessing input before passing it to any standard JSON parser.
Parses incomplete or malformed JSON strings into valid Python objects, handling truncated structures and optional JSON5 syntax extensions.
Extends Python's JSON serialization to handle numpy arrays, class instances, datetimes, OrderedDict, comments, and other non-standard types while preserving human readability.
Install it if you need to serialize non-standard Python types to JSON; skip it if you only work with standard JSON types.
See also json-five · json-numpy · json5kit