AI text tools

Broken JSON Fixer

Paste JSON that won’t parse. The tool removes the chat text around it, fixes the usual mistakes AI models and hand-edited files make, tells you exactly what it changed, and gives you valid JSON to copy.

Runs in your browser. Nothing is uploaded.

Output

Result

—Paste JSON to check and repair it

Repairs follow the most likely intent, but always check the values, especially if the input was cut off.

How this calculator works

If the input already parses, it is returned unchanged and marked valid, so you can also use this as a quick JSON validator and formatter.

Otherwise the tool first strips markdown code fences and any sentences before or after the data, then replaces curly quotes with straight ones. These are the most common reasons JSON copied from a chat window fails.

Next it repairs the structure: quotes around unquoted keys, double quotes instead of single, trailing commas removed, comments removed, Python’s True, False and None converted, and undefined or NaN replaced. Repairs are done by the open-source jsonrepair library, which parses the text rather than using find-and-replace, so commas or quotes inside your string values are left alone.

If the JSON was cut off, for example because a model hit its output limit, the missing brackets are closed. The structure becomes valid, but whatever came after the cut is still missing, so check the last items.

Everything runs in your browser. Nothing you paste is uploaded or stored.

Worked example

A ChatGPT reply that fails JSON.parse

  1. Input: “Here is the data: ```json {name: 'Ana', tags: ['a', 'b',], active: True} ```”.
  2. The fence and the sentence are removed, and the keys get quotes.
  3. Single quotes become double quotes, the comma after 'b' is removed, and True becomes true.
  4. Output: {"name": "Ana", "tags": ["a", "b"], "active": true}.

Questions people ask

Why does ChatGPT return invalid JSON?

Language models write JSON one token at a time, so they can add a friendly sentence, wrap the data in a code block, leave a trailing comma, use Python syntax or stop mid-object when they reach their output limit. Asking for JSON only, or using a provider’s structured-output mode, reduces this but does not always prevent it.

Can a cut-off response be fully recovered?

No. The fixer closes the open brackets so the data parses, but anything the model never wrote is lost. Ask the model to continue from the last complete item, then join the two parts.

Does it change my data values?

It changes syntax, not content. The one exception is undefined, NaN and Infinity, which JSON cannot represent; they become null. The list of fixes tells you when that happened.

Is this the same as a JSON validator?

It includes one: valid JSON is reported as valid and simply reformatted. Invalid JSON is repaired where possible, and if it cannot be, you get the parser’s error message.

Sources

Last reviewed October 2, 2026