Skip to content

Guides

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

ErrorWrongRight
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

ActionWhat it doesUse it for
FormatIndents with 2 spaces, 4 spaces or tabsReading and debugging
MinifyRemoves all spaces and line breaksSmallest size for APIs and configs
Sort keysPuts object keys in alphabetical orderComparing two JSON files

Step by step

  1. Open the JSON formatter and paste JSON, or open a .json file.
  2. Choose Format, Minify or Sort keys.
  3. 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