RadarTopicsBuildersWeeklyReads
Open Source Radar
mangiucugna/

json_repair

GitHubWebsite

json_repair is a Python library to repair malformed JSON from LLMs, APIs, logs, and user input. It can repair missing quotes, commas, brackets, and other issues, and supports schema-guided repairs and streaming. It offers a CLI and Python API for loading, repairing, and validating JSON.

5.1kstars
208forks
0issues
MITlicense
2023since
Star historydaily snapshots by VibeCrowd

Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).

Alternatives & relatedmatched by topic overlap
Reviewgenerated from repository data · Aug 5, 2026

What it is

json_repair is a Python library that repairs malformed JSON produced by LLMs, APIs, logs, and user input. It can fix syntax issues like missing quotes, commas, and brackets, and can also repair truncated values and stray prose. The project supports using the repair parser as a drop-in replacement for json.loads(), or as a schema-guided repair step. It includes a CLI and streaming support for repairing JSON as data arrives.

How it works

The library first attempts to parse with the standard library json loader and only falls back to a repair parser if strict parsing fails. If skip_json_loads is used, the repair parser is invoked directly. It also supports schema-guided repairs via a JSON Schema or Pydantic v2 model, with options for standard or salvage repair modes. It can repair JSON in streaming contexts by using stream_stable. It exposes functions like loads, load, repair_json, as well as a CLI interface for file-based operations and streaming.

Getting started

Install via pip as shown in the README:

pip install json-repair

Then you can use the library in code, for example:

import json_repair

good_json_string = json_repair.loads(bad_json_string)

Or use repair_json directly:

from json_repair import repair_json

good_json_string = repair_json(bad_json_string)

You can also repair with schema guidance:

from json_repair import repair_json

schema = {"type": "object", "properties": {"value": {"type": "integer"}}, "required": ["value"]}
repair_json('{"value": "1"}', schema=schema, return_objects=True)

For CLI usage:

pipx install json-repair

$ json_repair -h

The README shows how to skip the initial json.loads validation using skip_json_loads=True:

from json_repair import repair_json

good_json_string = repair_json(bad_json_string, skip_json_loads=True)

And how to use streaming:

stream_output = repair_json(stream_input, stream_stable=True)

Getting started notes

  • The project supports both standard JSON semantics and schema-guided repairs
  • It provides a Python API (loads, load, from_file) and a CLI with various options like --skip-json-loads, --schema, --strict, and --schema-repair-mode
  • The documentation includes examples for non-Latin characters handling and compatibility with json.dumps parameters

Release history and maintenance

Releases show ongoing fixes through v0.61.x, with recent updates in 2026-07-21 and prior days, indicating active maintenance. The latest release notes mention fixes for string parsing and JSON delimiter handling, and support for a fast-path when skip_json_loads is True.

Traction

  • Stars: 5062
  • Forks: 208
  • Open issues: 0
SharePost on XLinkedIn
All trending reposRevenue-verified startups →