json-repair

Report Abuse

Basic Information

json-repair is a Go library and command line tool designed to detect and fix malformed JSON produced by large language models and other sources. It is intended for Go developers and operators who need to convert broken or loosely formatted LLM outputs into valid JSON for downstream processing. The project offers a drop-in package for Go projects plus a terminal CLI and standalone binaries, enabling use in scripts and pipelines. It emphasizes zero external dependencies, consistent string results rather than error propagation, and a comprehensive suite of test cases to handle common anomalies. The repository includes examples, an online playground, Homebrew tap support and release artifacts to simplify installation and integration into developer workflows.

Links

Categorization

App Details

Features
Key features include native Go compatibility with a module install command and a small API exposing RepairJSON and MustRepairJSON functions, a terminal CLI that supports piping and file input, and zero external dependencies. The toolkit auto-detects and repairs many common LLM-induced problems such as mismatched or mixed quotes, unclosed arrays and objects, stray commas, improperly formatted booleans and nulls, embedded links and comments, and incorrect key-value constructs. It returns repaired JSON strings reliably, includes rich test cases demonstrating supported broken patterns, provides packaged binaries and a Homebrew tap for distribution, and is published under GPLv3 with contribution guidelines and a roadmap.
Use Cases
This repository helps teams and developers avoid parsing failures and manual cleanup when LLMs or other generators output invalid JSON. By automatically normalizing a wide range of syntax and structural anomalies into valid JSON strings, it reduces runtime errors and simplifies downstream data handling, logging, and integration with other services. The CLI enables quick fixes in shell pipelines and file-based workflows, while the Go library supports programmatic repair inside applications, CI pipelines and GitHub Actions. Rich test coverage and examples increase confidence in repairs, and provided binaries and package taps make it practical to deploy in development and production environments.

Please fill the required fields*