Common JSON Errors and How to Fix Them
The handful of syntax mistakes that cause almost all JSON parse failures, each shown as a broken snippet and its fix.
When JSON won't parse, it's nearly always one of a few recurring mistakes. Recognising them by eye saves you from guessing where the problem is.
Each example below shows the invalid form and the correction.
Trailing comma
A comma after the final element of an object or array is the single most common error. JavaScript allows it; JSON does not.
// Invalid
{ "a": 1, "b": 2, }
// Valid
{ "a": 1, "b": 2 }Single quotes
JSON strings require double quotes. Single quotes are invalid for both keys and values.
// Invalid
{ 'name': 'Ada' }
// Valid
{ "name": "Ada" }Unquoted keys
Every key must be a quoted string. Bare identifiers are a JavaScript shorthand, not JSON.
// Invalid
{ name: "Ada" }
// Valid
{ "name": "Ada" }Comments
JSON has no comment syntax. A // or /* */ block makes the whole document invalid.
// Invalid
{
// a note
"a": 1
}
// Valid
{ "a": 1 }Disallowed values
undefined, NaN, and Infinity are not JSON values. Use null for 'no value', and leave out keys whose value is undefined.
// Invalid
{ "count": undefined, "ratio": NaN }
// Valid
{ "count": null }Mismatched brackets
Every { needs a } and every [ needs a ], correctly nested. When a long document fails, the reported line is often where the parser gave up rather than where the missing bracket actually belongs — fix the structure from the outside in.
How to find the error fast
- 1Paste the text into a JSON formatter/validator.
- 2Read the reported line and column — start there.
- 3Check for one of the patterns above near that spot.
- 4Re-run until it parses cleanly.

