How to fix invalid JSON (common errors and fixes)
Updated 21 October 2026
Tool for this guide: JSON formatter
Short answer: paste the JSON into the JSON formatter and press Format. If it's invalid, you'll see the error and the exact line and column where it starts. Most errors are one of the five below.
The five most common JSON errors
| Error | Wrong | Right |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ana'} | {"name": "Ana"} |
| Unquoted key | {name: "Ana"} | {"name": "Ana"} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Comments | {"a": 1 // note} | Remove the comment |
Also check for undefined, NaN and unescaped line breaks inside strings; JSON doesn't allow them.
Format, minify or sort
| Action | What it does | Use it for |
|---|---|---|
| Format | Indents with 2 spaces, 4 spaces or tabs | Reading and debugging |
| Minify | Removes all spaces and line breaks | Smallest size for APIs and configs |
| Sort keys | Puts object keys in alphabetical order | Comparing two JSON files |
Step by step
- Open the JSON formatter and paste JSON, or open a .json file.
- Choose Format, Minify or Sort keys.
- Fix any error at the line and column shown, then copy or download.
JSON is parsed by your browser, so it's safe to paste API responses and config files.
Compare two JSON files
Format and sort both, then paste them into compare text in line mode to see every change.
Questions
Can it handle large files?
Yes, several megabytes work on a computer. Very large files may be slow on phones.
Is my JSON uploaded?
No. It stays in your browser.
Try it now
Paste JSON to format it with clean indentation, check it for errors, or minify it to one line.
Open json formatter