Common JSON Errors and How to Fix Them
Published November 29, 2026
Unexpected token, trailing commas, single quotes and other JSON syntax errors explained with examples, and how to find the exact line that's broken.
Why JSON is so strict
JSON looks like JavaScript, but its rules are much stricter so that every programming language reads it the same way. One character too many or too few makes the whole document invalid, and the error message ("Unexpected token", "Expected property name") doesn't always say where the problem is.
Find the error in seconds
Paste the JSON into the JSON formatter and click Validate. It tells you what's wrong in plain words with the exact line and column, and jumps the cursor there.
The most common errors
| Wrong | Right | Problem |
|---|---|---|
{"a": 1,} | {"a": 1} | Trailing comma after the last item |
{'a': 1} | {"a": 1} | Single quotes instead of double quotes |
{a: 1} | {"a": 1} | Property name without quotes |
{"a": 1 // note} | {"a": 1} | Comments aren't allowed in JSON |
{"a": 007} | {"a": 7} | Numbers can't have leading zeros |
{"a": NaN} | {"a": null} | NaN and Infinity aren't JSON |
{"a": 1 "b": 2} | {"a": 1, "b": 2} | Missing comma between items |
Less obvious errors
- Line breaks inside a string: write them as
\n, not by pressing Enter. - Curly quotes: text copied from Word or an email may have “smart quotes”; JSON needs straight "quotes".
- A BOM at the start: some Windows editors add an invisible character when saving. Save as "UTF-8 without BOM".
- Several objects in a row:
{}{}isn't valid; wrap them in an array[{}, {}].
Writing configuration by hand?
If quotes and commas get tiring, YAML may suit you better: it allows comments and uses indentation. Convert between the two with the YAML ↔ JSON converter, and bring spreadsheet data into JSON with CSV ↔ JSON.