JSON Repair: step by step
- Paste the broken JSON, a JavaScript object or a Python dict into the left box.
- The repaired, formatted JSON appears on the right, with a list of everything that was fixed.
- Check the fixes, then click Copy, or Replace my input with the fixed JSON to keep editing it.
- If something can't be repaired automatically, the exact line and a plain-English explanation are shown.
What JSON Repair fixes
| Problem | Before | After |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'name': 'Aung'} | {"name": "Aung"} |
| Curly “smart” quotes | {“city”: “Bangkok”} | {"city": "Bangkok"} |
| Unquoted keys | {id: 7} | {"id": 7} |
| Comments | {"a": 1 // note} | {"a": 1} |
| Python values | {"ok": True, "x": None} | {"ok": true, "x": null} |
| JavaScript values | {"n": NaN, "u": undefined} | {"n": null, "u": null} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Line break inside a string | a real new line | "line one\nline two" |
| Missing closing brackets | {"items": [1, 2 | {"items": [1, 2]} |
| Number formats | .5, +3, 1_000 | 0.5, 3, 1000 |
Repairs are made outside strings only, so a comma, quote or // inside real text (like a URL) is never touched.
Where broken JSON comes from
- JavaScript objects copied from code or the browser console: unquoted keys, single quotes and trailing commas are fine in JavaScript but not in JSON. In code, use
JSON.stringify(obj)instead of copying. - Python dicts printed with
print()orstr(): single quotes,True,None. Usejson.dumps(data)to get real JSON. - Config files such as
tsconfig.jsonor VS Code settings, which allow comments and trailing commas (that format is called JSONC). - Chat apps and word processors that turn straight quotes into curly ones.
- Truncated output from logs or a response that was cut off, which leaves brackets unclosed. The repair closes them, but check that no data is missing.
Check the result
Automatic repair guesses what was meant. It's right for the common mistakes above, but if a closing bracket was missing because the data was cut off, the repaired JSON will be valid yet incomplete. For an explanation of a specific error message, see JSON errors explained.
Frequently asked questions
Is it safe to paste private JSON here?
Yes. The repair runs in your browser and nothing is uploaded, so API keys or customer data never leave your device.
Can it fix any broken JSON?
It fixes the common syntax mistakes listed above. If the structure itself is ambiguous, for example a value missing in the middle, it shows the exact line and explains what's wrong so you can fix it by hand.
Does it change my data?
Only the syntax. Text, numbers and the order of keys stay the same, except that NaN and undefined (which JSON can't store) become null.
How do I fix JSON in code?
In JavaScript, the jsonrepair npm package does a similar job. In Python, json_repair is a common choice. Better still, fix the source: generate JSON with JSON.stringify or json.dumps.
Updated