JSON Repair
Paste broken JSON and get valid JSON back. The repairer handles the breakage you actually hit — trailing commas, single quotes, unquoted keys, // and /* */ comments, Python-style None/True/False, NaN and Infinity, missing commas, smart quotes, code-fence wrappers, and unterminated strings — then re-serialises clean, formatted JSON and lists every fix it applied. Runs entirely in your browser.
How to use the JSON Repair
Paste the JSON that won't parse, or load a file. If the input is already valid it's simply reformatted; otherwise the repairer parses it leniently and produces clean JSON, with a list of badges showing exactly what it changed — so you can see whether it stripped comments, quoted bare keys, removed a trailing comma, or closed an unterminated string. Pick your indentation, then copy the result.
The repairer is tolerant by design: it understands JSON5-style and JavaScript-object-literal conventions, Python's None/True/False, and common copy-paste damage like smart quotes and Markdown ```json fences. Where a value can't be a valid JSON number — a bare word, or NaN/Infinity — it makes a safe choice (quote the word, or use null) and tells you. Review the fixes before trusting the output, especially when a repair changes meaning, such as turning NaN into null.
Why JSON breaks, and how repair works
Strict JSON is unforgiving: keys must be double-quoted, strings can't use single quotes, comments are forbidden, trailing commas are illegal, and the only literals are true, false, and null. Yet the JSON people paste comes from places that bend those rules — JavaScript object literals, Python print output, config files written in JSON5, log lines truncated mid-string, or text an LLM wrapped in a code fence. The data is almost JSON, and the parser rejects the whole thing over one stray comma.
Repairing it means parsing leniently rather than strictly. This tool reads the input with a tolerant parser that accepts the common deviations and rebuilds a proper data structure, which it then serialises with the standard JSON serialiser — guaranteeing the output is valid. Trailing commas are dropped, single-quoted and backtick strings are re-quoted, unquoted keys are quoted, comments are removed, and language-specific literals are mapped: Python's None becomes null, True/False become lowercase booleans. Non-finite numbers like NaN and Infinity, which JSON simply cannot represent, are converted to null so the result is legal — a lossy but honest choice the tool flags for you.
Some damage is genuinely ambiguous. A missing comma between two values can be inferred, and an unterminated string can be closed at the line break, but these are guesses; the tool makes the most likely one and records it. Truly broken structure — mismatched brackets with no clear nesting — can't always be recovered, and the tool says so rather than producing nonsense. The point is to handle the 95% of real-world breakage that's mechanical, turning a frustrating parse error into clean, formatted JSON in one paste, while being transparent about every change so you stay in control of your data.
Common use cases
- LLM output. Clean JSON a model returned with comments, trailing commas, or a code-fence wrapper.
- Copy-paste from code. Convert a JavaScript or Python object literal into strict JSON.
- Config files. Turn JSON5 or commented config into plain JSON a strict parser accepts.
- Truncated logs. Recover a structure from a log line that was cut off mid-string.