Why AI models return broken JSON
Language models write JSON one token at a time, the same way they write sentences. That leads to familiar mistakes:
- Wrapping the JSON in
```jsoncode fences or adding “Here's your data:” before it. - Trailing commas, comments, and single quotes that JavaScript allows but JSON doesn't.
- Python-style
True,FalseandNone. - Unquoted keys, curly “smart” quotes, and
NaNorundefinedvalues. - Output that stops mid-way because it hit the length limit.
What this tool fixes
All of the above. It pulls the JSON out of the surrounding text, repairs the syntax, closes anything left open, and lists exactly what it changed. Then you can copy or download valid, formatted JSON.
If your JSON keeps getting cut off, the reply probably hit the model's output limit. The Context Window Calculator shows the limits for each model.
Frequently asked questions
Is my JSON uploaded?
No. Everything is processed in your browser.
Can it fix JSON that was cut off?
Yes. It closes open strings, arrays and objects so the data that did arrive becomes valid JSON. Anything after the cut-off point is still missing, so you may need to ask the AI to continue.
Will it change my data?
It only fixes syntax. Values stay the same, except NaN and undefined (which JSON doesn't allow) become null.
How do I stop the AI returning broken JSON?
Ask for 'only valid JSON, no code fences or explanation', or use the provider's structured output (JSON mode) option if you use the API.