json-repair
A Go library and CLI that automatically detects and fixes malformed JSON output from large language models, such as unclosed brackets, mixed quotes, or trailing commas.
json-repair fixes JSON anomalies commonly produced by large language models, such as single quotes, unescaped line feeds, improperly capitalized booleans and null, mixed quote styles, unclosed arrays or objects, standalone brackets, malformed key-value pairs, and inline comments. It always returns a string result rather than raising an error on malformed input.
It has zero external dependencies and includes a test suite of known broken JSON patterns. It can be used as a Go library or from the command line, where it can be chained with other commands through pipes.
It is written in Go and licensed under GPL-3.0.