LLM JSON repair
Language models are asked to return JSON constantly, and they constantly return JSON that almost parses — wrapped in a markdown fence, sprinkled with trailing commas, using single quotes, or cut off mid-object when the response hit a token limit. This tool applies the standard sequence of safe repairs and then validates the result with a real parser, so you get usable JSON instead of a stack trace.
How it works
The repair runs as an ordered pipeline. First it strips markdown fences and
any prose before the first { or [ and after the last matching bracket. Then
it normalizes smart quotes to straight quotes, converts single-quoted
strings and keys, quotes bare keys, and removes trailing commas before
closing brackets. Finally it scans for unbalanced braces, brackets, and an
unterminated string — the signature of a truncated response — and appends the
closing characters needed to make it parse. Every result is run through
JSON.parse to confirm validity before it is shown.
Notes and limits
- Repairs are syntactic. Quotes, commas, and brackets get fixed; your values are not interpreted or altered.
- Truncation recovery is best-effort. Closing an interrupted structure can drop a half-written final value — the tool tells you when it closed brackets so you can spot-check.
- Review when warned. If the tool reports it normalized quotes or balanced brackets, glance at the output around the end of the data.
- Everything is local. Nothing is uploaded; paste sensitive payloads freely.