Most JSON syntax errors fall into a small handful of repeat offenders. Here's what they look like and how to fix each one.
Trailing Commas
JSON does not allow a comma after the last item in an object or array — unlike some programming languages that permit it.
// Invalid
{ "a": 1, "b": 2, }
// Valid
{ "a": 1, "b": 2 }
Single Quotes Instead of Double Quotes
JSON strings and keys must use double quotes — single quotes are valid in JavaScript object literals but not in JSON itself.
// Invalid
{ 'name': 'Alex' }
// Valid
{ "name": "Alex" }
Unquoted Keys
Every key in a JSON object must be a quoted string, even though many programming languages allow bare identifiers as object keys.
// Invalid
{ name: "Alex" }
// Valid
{ "name": "Alex" }
Missing or Mismatched Brackets
Every { needs a matching }, and every [ needs a matching ]. This sounds obvious, but it's the most common source of errors in deeply nested JSON, where it's easy to lose track while editing by hand.
Using undefined or Comments
JSON has no concept of undefined (only null) and does not support comments of any kind — not //, not /* */. Both are valid in JavaScript but will always cause a JSON parse to fail.
The Fastest Way to Catch These
Rather than scanning by eye, running your JSON through a validator points you directly to the line and character where parsing failed, which is almost always faster than manually reviewing a large payload for one of these five issues.
Have a JSON error you can't spot manually?
Find the Error Now