Json Repair

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

Last verified:

Visit Json Repair

What is Json Repair?

JSON Repair is a free online tool and Python library designed to fix malformed JSON, particularly output from large language models (LLMs) that often contains syntax errors. The tool repairs common issues like trailing commas, missing quotes, stray comments, invalid true/false/null values, and incomplete objects or arrays. It also provides JSON Schema validation to enforce expected types, defaults, and structural constraints with schema-guided coercion (such as converting string

Json Repair pricing

Pricing model: Freemium

Free tier only - the online JSON Repair demo at mangiucugna.github.io/json_repair is completely free with no paid plans. The Python library is open-source under MIT license and available on PyPI via pip install json-repair. Installing locally allows offline/private processing without API limits. The project accepts donations via GitHub Sponsors for the maintainer's beer budget but has no mandatory fees or subscription tiers.

Json Repair pros

  • Fixes trailing commas in JSON automatically
  • Adds missing quotation marks around keys and values
  • Removes stray comments from JSON input
  • Repairs incomplete objects and arrays
  • Fixes invalid true/false/null literals
  • Removes hallucinated prose from LLM outputs
  • Provides JSON Schema validation with type coercion
  • Shows transparent repair logs for debugging
  • Pretty-prints output for easy copying
  • Auto-validates and formats as you type
  • Works as drop-in replacement for json.loads()
  • Lightweight Python package with no external dependencies
  • Supports non-Latin characters with ensure_ascii=False
  • Includes CLI tool for file-based repair
  • Handles streaming JSON with stream_stable option
  • Skips standard JSON parser with skip_json_loads=True for speed
  • Returns parsed objects directly with return_objects=True

Json Repair cons

  • No paid plans - only free tier available
  • Online demo requires internet connection
  • May return empty string for severely broken JSON
  • No built-in GUI beyond the web demo
  • Does not catch IO-related exceptions automatically
  • Frequent minor updates require careful version pinning
  • 0.x version indicates pre-1.0 API stability
  • No commercial support available
  • Schema repair limited to standard and salvage modes

Frequently asked questions about Json Repair

Does this work for AI/LLM responses?

Yes. json_repair is specifically tuned for messy model output from LLMs. It removes prose, repairs syntax errors like missing brackets or quotes, and keeps structured data intact. This addresses the common issue where LLMs return incomplete or incorrectly formatted JSON strings.

Can I trust the repaired JSON?

Every repair action is logged so you can review context and see exactly what changed and where before sending payloads to production systems. The transparent logging shows every repair step, making the output trustworthy for production use.

What if I need offline or private processing?

Install the library locally using pip install json-repair to repair sensitive JSON without hitting the public API. This enables offline processing and keeps your data private on your local machine.

How do I report issues or request features?

Open an issue on GitHub and include a sample payload. The demo page URL is a permalink that updates live as you edit, so you can use the share button to copy a reproducible permalink for reference when reporting issues.

What types of JSON errors does this fix?

The tool fixes trailing commas, missing quotes, stray comments, invalid true/false/null literals, incomplete objects and arrays, missing quotation marks, improperly formatted values, unescaped characters, corrupted key-value structures, and removes extra non-JSON characters like comments.

Can I use this as a replacement for json.loads()?

Yes, json_repair can completely replace json.loads() as a drop-in replacement. Use import json_repair and decoded_object = json_repair.loads(json_string) for resilient parsing that handles invalid JSON gracefully.

How do I preserve non-Latin characters like Chinese or Japanese?

Pass ensure_ascii=False to repair_json() to preserve non-Latin characters in the output. Without this parameter, characters like Chinese, Japanese, or Korean will be escaped as Unicode sequences like 统一码.

Is there a command-line interface available?

Yes, install the CLI with pipx install json-repair. The CLI supports options like -i for inline replacement, -o for output file, --indent for indentation spacing, and --ensure_ascii. It can read from files or stdin and write repaired JSON to stdout or a target file.

How do I handle streaming JSON data?

Pass stream_stable=True to repair_json() or loads() to make streaming work properly. This ensures stable parser behavior for chunked or stream-like inputs where JSON data arrives incrementally rather than all at once.

Categories

Use cases

Browse all AI tools on NeedAnAI