Tools

JSON repair for LLM output

Fix the broken JSON language models return — single quotes, trailing commas, comments, Python literals, truncated output — and pull it out of the surrounding chatter.

Runs in your browserAI developer tools2.4K
Free

Input

0 B

Result

The result will appear here.

Ask a model for JSON and you will sooner or later get something JSON.parse rejects: keys without quotes, a trailing comma, a // comment, None instead of null, or an answer cut off mid-object when it ran out of tokens — often wrapped in a friendly sentence and a code fence. This tool finds the JSON in whatever you paste and repairs it with jsonrepair (josdejong/jsonrepair, ISC), the library behind many JSON editors and agent frameworks, then prints valid, indented JSON you can use at once.

How it works

  • It first locates the JSON: the contents of a ```json code block if there is one, otherwise everything from the first { or [; if trailing prose after the last bracket stops the repair, it is cut off and the repair retried.
  • jsonrepair then adds missing quotes, turns single quotes into double quotes, removes trailing commas and comments, converts Python's None, True and False, escapes stray quotes inside strings, and closes brackets left open.
  • Input that is already valid is reformatted and marked as such, so you can also use the tool as a plain formatter.
  • The stats say where the JSON was found and how many nodes and levels of nesting it has, and the result can be indented by 2 or 4 spaces or minified.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

Can it recover a response that was cut off?
It makes it parse, which is not the same as recovering it. Open strings and brackets are closed, and a key cut off before its value gets null. Whatever the model never wrote is still missing, so check the last items, or better, raise max_tokens and ask again.
What if the answer contains several JSON blocks?
Only the first fenced block, or failing that the text from the first bracket, is repaired. Paste the blocks one at a time if you need them all; if you control the prompt, asking for a single top-level object or array avoids the problem.
How do I stop models returning broken JSON in the first place?
Use the provider's structured output mode where it exists — OpenAI's response_format with a JSON schema, Gemini's responseSchema, or tool calling on Claude — which constrains generation to valid JSON. Repair is the fallback for models and gateways that do not offer it, and for logs you already have.

The open-source behind it

This tool runs on josdejong/jsonrepair, released under ISC. If you need the same behaviour inside your own program, that is the library to reach for.

josdejong/jsonrepair

Also known as

  • json repair
  • fix json online
  • repair broken json
  • llm json fix
  • invalid json fixer
  • jsonrepair