Invalid JSON? The 10 Most Common Errors and How to Fix Them

Updated 17 October 2026

“Unexpected token” tells you something is wrong but rarely what. These are the mistakes behind almost every invalid JSON document, with the fix for each.

JSON is strict by design: a single stray comma makes a whole document invalid. The good news is that nearly every error falls into a handful of patterns. Paste your JSON into the validator to get the exact line and column, then match it against the list below — or try the Fix JSON page, which repairs many of these automatically.

The ten most common JSON errors

1. Trailing comma

JSON does not allow a comma after the last item in an object or array, even though JavaScript does.

✗ {"a": 1, "b": 2,}
✓ {"a": 1, "b": 2}

2. Single quotes

Strings and keys must use double quotes.

✗ {'name': 'Ada'}
✓ {"name": "Ada"}

3. Unquoted keys

Every object key must be a double-quoted string.

✗ {name: "Ada"}
✓ {"name": "Ada"}

4. Comments

Standard JSON has no comment syntax. Some tools accept “JSONC”, but JSON.parse and most APIs do not.

✗ {"debug": true // remove me
}
✓ {"debug": true}

5. Python or JavaScript literals

Only lowercase true, false and null are valid. NaN, Infinity and undefined have no JSON equivalent.

✗ {"ok": True, "v": None, "n": NaN}
✓ {"ok": true, "v": null, "n": null}

6. Missing comma

Items must be separated by commas.

✗ {"a": 1 "b": 2}
✓ {"a": 1, "b": 2}

7. Unescaped characters in strings

Backslashes and double quotes inside a string must be escaped (\\ and \"). Raw line breaks inside strings must be written as \n.

✗ {"path": "C:\new\file"}
✓ {"path": "C:\\new\\file"}

8. Curly “smart” quotes

Text copied from word processors or chat apps often contains curly quotes, which are not valid.

✗ {“title”: “Hello”}
✓ {"title": "Hello"}

9. Leading zeros and other number formats

Numbers cannot start with 0 (except 0 itself) and must be decimal. Store codes such as ZIP codes as strings.

✗ {"zip": 02134, "hex": 0xFF}
✓ {"zip": "02134", "hex": 255}

10. More than one top-level value

A JSON document is a single value. Wrap multiple objects in an array — or, if a tool expects JSON Lines, use one object per line.

✗ {"a": 1}{"b": 2}
✓ [{"a": 1}, {"b": 2}]

Reading the error message

Browsers report errors in slightly different words, but they point to the same place: the first character the parser could not accept. The real mistake is often just before that point — a missing comma at the end of the previous line, or an unclosed string several lines up.

A note on very large numbers

JSON itself allows numbers of any size, but JavaScript stores numbers as 64-bit floating point values, so integers above 9,007,199,254,740,991 (253 − 1) lose precision when parsed in a browser. IDs from some APIs exceed this — which is why many APIs send large IDs as strings. Our formatter warns you when your input contains numbers that would be rounded.

Open the JSON formatter →

Frequently asked questions

The usual culprits are invisible or easy to miss: a trailing comma, curly quotes pasted from a document, or a comment. A validator shows the exact line and column of the first problem.
No. Standard JSON (RFC 8259) has no comment syntax. Some configuration tools accept JSON with comments (JSONC), but JSON.parse and most APIs reject it.
No. Strings and object keys must use double quotes.

Tools and further reading