How to use JSON repair
- Paste the broken text into Broken JSON. The sample shows several common mistakes at once.
- Pick an Indent for the output.
- Read the notice at the top: either “This was already valid JSON” or “Repaired:” followed by what was changed.
- Copy or download the Repaired JSON, and check the Fixes applied list.
If the text cannot be repaired, the tool names the line, column and reason.
What it does and when to use it
Strict JSON rejects many things people write by habit: comments in a config, a trailing comma after the last item, single quotes, keys without quotes, True and None copied from Python, or NaN from a JavaScript log. Data also arrives broken: a response cut off mid-stream, a JSONP callback wrapper, several objects pasted one after another, or a code block copied from documentation or a chatbot. This tool turns all of these into one valid JSON document you can parse.
Use it when a parser throws “Unexpected token” and you just want working data. To see exactly where the first error is without changing anything, use the JSON validator. To convert a real JavaScript object literal into JSON, the JS to JSON converter uses the same tolerant reader. For JSONC files such as tsconfig.json, JSONC to JSON strips comments only.
What it fixes
- Comments:
//,/* */and# - Trailing and extra commas; empty array slots become
null - Single, curly and backtick quotes; unquoted keys and bare-word values
- Python
True,False,None; JavaScriptundefined,NaN,Infinity - Hex, octal and binary numbers,
+1,.5and5. - Missing commas and colons,
=instead of:, semicolons between properties - Unclosed brackets at the end, mismatched closing brackets
- Markdown code fences, JSONP wrappers,
const x =andmodule.exports =prefixes - Several top-level values, which are wrapped in an array
How it works
The text is first tried with the strict parser. If that succeeds, it is only re-indented. Otherwise a tolerant tokenizer reads it piece by piece, records each kind of fix with a count, and builds the value. The value is then printed with JSON.stringify, so the output always follows RFC 8259. It all happens in your browser.
Worked examples
A Markdown code fence marked json, wrapped around {"name": "Asha", "tags": ["a", "b",],}, gives:
Repaired: Removed a Markdown code fence; Removed trailing commas (2×).
{"name":"Asha","tags":["a","b"]}
callback({"ok": true, "count": 0x1F}) gives {"ok":true,"count":31}. Two objects pasted together, {"a":1}{"a":2}, become [{"a":1},{"a":2}].
Limits and tips
- Repairs are guesses based on common mistakes. A missing quote in the middle of a long string can be “fixed” into a different structure than you meant, so check the result.
- An unterminated string cannot be repaired; the tool reports where it starts.
Frequently asked questions
Does the repair change my data?
Why are my large numbers different after repair?
Can it fix JSON copied from a chatbot answer?
Is this the same as JSON5?
Does it run my code?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.