How do I fix invalid JSON?
Features & Capabilities
JSON Copilot fixes invalid JSON two ways. The validator points at each syntax error so you can correct it by hand, and the AI Fix & Validate action repairs the whole document in one click. Paste your broken JSON into the editor and use whichever is faster.
Fix it in one click
- Paste the broken JSON into the editor.
- Open AI Copilot from the left sidebar and choose Fix & Validate.
- The AI returns valid, formatted JSON. Click Apply to Input to replace your text.
Common reasons JSON is invalid
| Problem | Looks like | Fix |
|---|---|---|
| Unquoted key | name: "Ada" | Wrap the key in double quotes |
| Single quotes | 'Ada' | JSON requires double quotes |
| Trailing comma | ["a", "b",] | Remove the comma after the last item |
| Missing bracket | { "a": 1 | Close the object or array |
| Python literals | True / None | JSON uses true and null |
| Comments | // note | Standard JSON has no comments |
For the full rules, see JSON syntax rules.
Fix it by hand with the validator
The editor validates as you type and marks the exact line and column of each error with a message. Work down the list, fix each one, and the red markers clear when the JSON parses. This keeps everything in your browser and costs nothing. See understanding validation errors for what each message means, or open the JSON validator.
Fix it automatically with AI
When a payload has several problems at once, the Fix & Validate action is faster. It reads the broken text, repairs the syntax, and returns valid JSON you can apply in one click. Here is a typical repair:
{
name: 'Ada',
"roles": ["admin", "editor",],
"active": True
}
{
"name": "Ada",
"roles": ["admin", "editor"],
"active": true
}
Fix changes syntax, not your data. It quotes keys, removes trailing commas, and closes brackets without adding or renaming fields. It is an AI Copilot action, so it needs sign-in and uses credits priced by the size of your JSON. See AI Copilot features and credits and pricing.
Once the JSON is valid, format it to clean up the indentation, or explore it in the tree view.
Still Have Questions?
Check out our other FAQ topics or return to the JSON Copilot app