jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON Repair — Fix LLM-Mangled JSON

trailing commas · single quotes · unquoted keys · smart quotes · JS comments · BOM

Paste broken JSON (or paste an LLM response that contains JSON mixed with prose — the tool extracts the JSON block). The right panel shows the repaired output and a change log lists every fix applied. Best-effort: for truly mangled output (truncated mid-token, mixed encodings), some recoveries fail.

Paste JSON to repair.

Change log

    How to repair JSON

    1. Paste broken JSON (or paste an LLM response that contains JSON mixed with prose — the tool extracts the JSON block).
    2. The right panel shows the repaired output. A change log below lists every fix applied ("removed trailing comma on line 12", "wrapped unquoted key name in quotes").
    3. If the repair confidence is low, the banner says Best-effort repair — review before using.
    4. Copy the result, or Format to jump straight to json-formatter with the cleaned output.

    What it fixes

    What it will not do: touch the inside of a string

    Every fix above is applied by a single left-to-right scan that always knows whether it is inside a string. That distinction is the whole difference between a repair tool and a corruption tool.

    A pattern-replacement approach — strip // to end of line, delete a comma before ], straighten curly quotes — also matches inside string values, where those characters are data. {"a": "x // y"} loses everything from the slashes on. {"a": "it's fine"} has its apostrophes read as quote marks. {"note": "1, ]"} quietly becomes {"note": "1]"} — which still parses, so nothing reports a problem and your data is simply different now. That last one is the reason this was rewritten: a repair that fails loudly is fine, and one that succeeds wrongly is not.

    Valid JSON therefore comes back unchanged, with an empty change log, whatever its strings contain.

    FAQ

    Why is this a "best effort"?

    Some breakage is genuinely ambiguous — a number written "1,234" could be one number or two, and nothing can tell which. A truncated document is closed off at the end, which recovers the part that arrived but cannot invent the part that did not. The change log lists every fix applied; if the result still doesn't parse, the remainder needs a person.

    Will it handle JSON5?

    Yes. Comments, trailing commas, unquoted keys, single quotes, hex numbers, leading +, and .5 / 5. numbers are all handled. JSON5's \-continued strings and its Infinity are converted rather than preserved — Infinity becomes null, because JSON has no way to write it.

    Why did my LLM output extract incorrectly?

    If your LLM put multiple JSON snippets in one response (e.g. two code fences), the tool grabs the first object/array span only. Split the response by hand before pasting.

    Will it work offline?

    Yes — after the page loads. The repair runs locally on your browser.