JSON Repair
Auto-fix broken JSON: trailing commas, single quotes, unquoted keys, comments, and Python literals
Shortcuts: Ctrl+Enter run · Ctrl+L clear · Ctrl+D download
About JSON Repair
JSON Repair automatically fixes common JSON syntax errors — trailing commas, single quotes, unquoted keys, Python literals (True/False/None), comments, and more. It is invaluable when working with JSON generated by LLMs, exported from non-standard tools, or hand-edited by non-developers who may not know the strict JSON syntax rules.
- ✓Fixes trailing commas after the last array element or object property
- ✓Converts single quotes to double quotes throughout the document
- ✓Adds missing quotes around unquoted object keys
- ✓Converts Python literals: True → true, False → false, None → null
- ✓Strips single-line (//) and multi-line (/* */) comments
Why "Almost JSON" Is Everywhere — and How Repair Works
Strict JSON parsers reject anything that deviates from RFC 8259, even by a single character. In practice, though, a huge amount of JSON-like text in the real world is "almost" valid — close enough for a human to read, but just different enough to make `JSON.parse` throw. JSON Repair exists to bridge that gap automatically.
Where almost-JSON comes from
- ·Large language models — LLMs generate text token by token and frequently produce trailing commas, unbalanced brackets in long outputs, or Python-flavored literals if trained heavily on Python code
- ·Hand-edited config files — a developer adds one more entry to an array and forgets to remove the trailing comma, or pastes from a JS file where single quotes are valid
- ·Cross-language exports — Python's `str(dict)` produces single-quoted, `True`/`False`/`None` text that looks like JSON but is not
- ·Logs and copy-pasted snippets — JSON embedded in log lines often has surrounding text, truncation, or escaped quotes that need cleanup before it parses
A side-by-side look at common fixes
// Input — common LLM/Python-style issues
{
'name': "Alice",
active: True,
role: None,
tags: ["admin", "editor",], // trailing comma + comment
}
// Repaired — strict, parseable JSON
{
"name": "Alice",
"active": true,
"role": null,
"tags": ["admin", "editor"]
}Notice that several distinct problems were fixed in one pass: single quotes converted to double quotes, an unquoted key quoted, Python literals converted to JSON literals, a trailing comma removed, and a comment stripped. Doing this by hand across a large document is tedious and error-prone — automating it is the entire point of the tool.
What automatic repair can and cannot fix
- ·Reliably fixable — trailing commas, quote style, unquoted keys, Python literals, comments, and many missing-comma situations where the structure is otherwise intact
- ·Sometimes fixable — missing closing brackets at the end of truncated output, where the repairer can infer the intended structure from context
- ·Not fixable — content that is fundamentally not JSON-shaped (free text, mixed formats, binary data), or structure so broken that multiple valid interpretations exist
Tip: Always inspect the repaired output before relying on it in production code. Auto-repair makes a best-effort guess about intent — for genuinely ambiguous input, run the result through the JSON Validator to confirm it is now strictly valid, and sanity-check the values themselves.
A typical recovery workflow
- ·1. Paste the broken text into JSON Repair and review the corrected output side by side with the original
- ·2. Run the result through the JSON Validator to confirm it now parses according to spec
- ·3. Format it with the JSON Formatter for readability, or minify it with the JSON Minifier if it is headed over the network