mangiucugna/json_repair

Repair malformed JSON from LLMs, APIs, logs, and user input in Python.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 30 minutes ago
Added to GitGenius on September 13th, 2026
Created on September 6th, 2023
Open Issues & Pull Requests: 0 (+0)
GitHub issues: Enabled
Number of forks: 216
Total Stargazers: 5,096 (+0)
Total Subscribers: 11 (+0)

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 0
New in 7 days: 1
Closed in 7 days: 1
Avg open age: N/A days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 1
Closed in 7 days: 1
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • bug (90)

Detailed Description

json_repair is a Python library that repairs malformed JSON from language models, APIs, logs, and user input.

The tool addresses the common problem of improperly formatted JSON output, particularly from large language models that may omit quotation marks, commas, brackets, or include stray text. It works by parsing broken JSON and reconstructing valid output, fixing syntax errors such as missing quotes, misplaced commas, unescaped characters, and incomplete key-value pairs. The library handles Python-style tuples by converting them to JSON arrays, recognizes boolean and null values case-insensitively, and auto-completes missing fields with reasonable defaults like empty strings or null values. It can also strip out comments and extraneous non-JSON characters while preserving the intended data structure.

Developers should adopt this tool if they work with JSON output from language models or other unreliable sources where standard parsing fails. It works as a drop-in replacement for json.loads() or as a schema-guided repair step, making it suitable for pipelines that need to handle imperfect JSON without manual intervention. The library is lightweight and designed specifically for the kinds of mistakes that language models typically make, rather than attempting to handle arbitrary malformed JSON.

The project shows active maintenance with responsiveness to issues and pull requests. Development includes regular updates to handle new edge cases and improvements to the repair logic. The maintainer has documented the tool thoroughly with a live demo and audio overview available for users to test their specific use cases before adoption.