json_repair
json_repair is a Python library that fixes malformed JSON from LLMs, APIs, logs, and user input by repairing syntax errors like missing quotes, commas, and brackets. It works as a drop-in replacement for json.loads() or as a standalone repair tool with optional schema validation.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | mangiucugna/json_repair |
| Owner | mangiucugna |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 5k |
| Forks | 205 |
| Open issues | 0 |
| Latest release | v0.61.2 (2026-07-05) |
| Last updated | 2026-07-05 |
| Source | https://github.com/mangiucugna/json_repair |
What json_repair is
The library provides repair_json(), loads(), and load() functions that attempt stdlib json.loads() first, then fall back to a custom repair parser for invalid JSON. It supports streaming, Pydantic schema validation, non-Latin characters, and offers performance tuning via skip_json_loads and strict modes.
Get the json_repair source
Clone the repository and explore it locally.
git clone https://github.com/mangiucugna/json_repair.gitcd json_repair# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Requires Python 3.10+; verify your runtime supports this minimum version.
- By default, json_repair validates with stdlib json.loads() first, then repairs only on failure; use skip_json_loads=True only if input is known to be invalid, as the repair parser may alter valid JSON.
- For non-ASCII characters (Chinese, Japanese, Korean), pass ensure_ascii=False to preserve characters instead of converting to Unicode escapes.
- The repair parser may infer reasonable defaults (null, empty strings) for missing values; use strict=True if you need the parser to error on ambiguous input instead.
- Integrate with Pydantic or json-schema for schema-guided repair; the library accepts json.dumps() parameters for serialization control.
When to avoid it — and what to weigh
- Strict Data Integrity Requirements — If you cannot tolerate any automatic 'guessing' at corrections, json_repair's default behavior of inferring missing values (null, empty strings) may introduce unintended changes.
- High-Performance Streaming JSON — For very large JSON streams where every millisecond matters, the fallback repair parser overhead may be noticeable; pre-validation or custom parsing may be faster.
- Heavily Custom JSON Semantics — If you need non-stdlib JSON behavior or support for exotic formats, this library is built on Python's standard json module and may not suit specialized use cases.
- Zero Data Loss Scenarios — When truncated or incomplete JSON cannot be safely auto-completed (e.g., financial records), the library's auto-completion defaults may mask missing critical data.
License & commercial use
MIT License. Permissive, OSI-approved license allowing unrestricted use, modification, and distribution in commercial and private projects, with no warranty.
MIT is a permissive OSI license with no restrictions on commercial use. You may use json_repair in proprietary software, SaaS, and closed-source products without licensing fees or attribution requirements. Review your own license compliance obligations.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
json_repair parses untrusted JSON input. Consider: the repair parser may accept and 'fix' ambiguous inputs, potentially masking malformed or malicious structures; always validate the output against an expected schema before use. No security audit status is documented. For sensitive data (PII, credentials), ensure repair operations do not introduce unintended exposure of truncated or incomplete values.
Alternatives to consider
rapidjson / orjson
High-performance JSON parsing, but do not repair malformed JSON; best used as a strict first-pass parser with json_repair as a fallback.
jsonschema + manual validation
Schema-driven validation without automatic repair; useful if you need to reject invalid input instead of guessing at corrections.
LLM prompt engineering
Prevent malformed JSON at the source by improving LLM prompts and output constraints; eliminates the need for repair altogether.
Build on json_repair with DEV.co software developers
Integrate json_repair with pip install json-repair and start repairing malformed JSON in minutes. See the live demo or check GitHub for examples.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
json_repair FAQ
Does json_repair guarantee the repaired JSON matches the original intent?
Will json_repair slow down my code if I pass valid JSON?
Can I use json_repair with Pydantic?
What happens if the JSON is too broken to repair?
Work with a software development agency
Need help beyond evaluating json_repair? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and ai frameworks integrations — and maintain them long-term.
Ready to handle imperfect JSON?
Integrate json_repair with pip install json-repair and start repairing malformed JSON in minutes. See the live demo or check GitHub for examples.