10 Common JSON Errors and How to Fix Them
Trailing commas, single quotes, unquoted keys, and more — the ten JSON mistakes that break parsers most often, with the fix for each.
JSON is strict, and that strictness is a feature — it means any compliant parser accepts the same documents. But it also means small mistakes break everything. Here are the ten errors that trip people up most, and exactly how to fix each one.
1. Trailing commas
The single most common mistake. JavaScript tolerates them; JSON does not.
{ "a": 1, "b": 2, } ← invalid
{ "a": 1, "b": 2 } ← fixed
Remove the comma after the final element in any object or array.
2. Single quotes
JSON strings and keys require double quotes.
{ 'name': 'Ada' } ← invalid
{ "name": "Ada" } ← fixed
3. Unquoted keys
Object keys are strings, so they must be quoted — even simple identifiers.
{ name: "Ada" } ← invalid
{ "name": "Ada" } ← fixed
4. Comments
Standard JSON has no comment syntax. Both // and /* */ cause errors.
{ "a": 1 } // note ← invalid
If you need comments, use JSONC or YAML for the source and strip/convert before parsing.
5. Missing commas between items
Forgetting a comma between pairs produces “unexpected string”.
{ "a": 1 "b": 2 } ← invalid
{ "a": 1, "b": 2 } ← fixed
6. Unclosed brackets or braces
Every { needs a } and every [ needs a ]. A missing one yields “unexpected end of JSON input”. Count your delimiters or let an editor match them.
7. Wrong number formats
JSON numbers are plain decimals. These are all invalid:
01 (leading zero)
+5 (leading plus)
0xFF (hex)
.5 (must be 0.5)
8. Undefined and NaN
undefined, NaN, and Infinity are JavaScript values, not JSON. Only null represents absence. Replace them with null or a real number.
9. Unescaped special characters in strings
Control characters and quotes inside strings must be escaped.
{ "path": "C:\Users" } ← invalid (\U)
{ "path": "C:\\Users" } ← fixed
Use \", \\, \n, \t, and \uXXXX as needed.
10. Duplicate keys
{ "id": 1, "id": 2 }
This parses, but the result is undefined behaviour — most parsers keep the last value, silently discarding the first. Avoid duplicate keys entirely; if you are merging data and worried about collisions, decide explicitly which value should win.
How to catch these fast
Eyeballing JSON for these mistakes is slow. A live validator that points to the offending line and column turns a minutes-long hunt into a quick fix. Our merge tool validates every input as you type and refuses to merge until each one is well-formed — see our validation guide for more on reading parser errors.
Prevention beats debugging
A few habits eliminate most of these errors before they happen:
- Let your editor format JSON on save (it will reveal mismatched brackets).
- Generate JSON with
JSON.stringifyrather than building strings by hand. - Validate any JSON you receive or paste before processing it.
Get those in place and the ten errors above mostly stop occurring — and when one slips through, you will know exactly where to look.
Ready to merge your JSON?
Combine files or snippets in your browser — free and private.
Open the merge toolKeep reading