RealAlexandreAI/json-repair

🔧 Repair JSON!Solution for JSON Anomalies from LLMs.

What it solves

Large Language Models (LLMs) often produce JSON output that is syntactically incorrect or malformed (e.g., missing brackets, single quotes instead of double quotes, or trailing commas). This project provides a toolkit to automatically detect and repair these anomalies to ensure the output can be parsed by standard JSON libraries.

How it works

The library identifies common LLM-generated JSON errors and corrects them. It can be used as a Go library, a command-line interface (CLI) tool, or via an API that supports advanced repair behaviors. It also supports schema-guided repair, where it uses JSON Schema objects to validate and salvage matching fragments of the data.

Who it’s for

Developers building LLM-powered applications who need to ensure that the AI's structured output is reliable and reliable for downstream processing.

Highlights

  • Zero Dependencies: A lean tool with no external dependencies.
  • Schema-Guided Repair: Supports standard and salvage modes using JSON Schema to recover data.
  • Broad Error Support: Fixes issues like unclosed arrays, mixed quotes, improper formatting, and comments within JSON.
  • CLI Support: Includes a terminal CLI that can be chained with command pipes.
  • Go Compatibility: Specifically designed for seamless integration into Go projects.

Related

  • Project
  • Project
  • Project
  • Project
  • Project