curly{bits}

curlybits / JSON Formatter / JSON Repair

JSON Repair: Fix Broken JSON

Paste JSON that won't parse and get valid, formatted JSON back straight away. The repair handles the mistakes that turn up most: trailing commas, single or curly quotes, unquoted keys, comments, Python's True and None, missing commas, and brackets that were never closed. Your original text stays in the box, so you can compare.

Input JSON
Formatted output

      

JSON Repair: step by step

  1. Paste the broken JSON, a JavaScript object or a Python dict into the left box.
  2. The repaired, formatted JSON appears on the right, with a list of everything that was fixed.
  3. Check the fixes, then click Copy, or Replace my input with the fixed JSON to keep editing it.
  4. If something can't be repaired automatically, the exact line and a plain-English explanation are shown.

What JSON Repair fixes

ProblemBeforeAfter
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 stringa real new line"line one\nline two"
Missing closing brackets{"items": [1, 2{"items": [1, 2]}
Number formats.5, +3, 1_0000.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() or str(): single quotes, True, None. Use json.dumps(data) to get real JSON.
  • Config files such as tsconfig.json or 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