Common JSON Errors (and How to Fix Them)
The JSON syntax mistakes that break parsers most often — trailing commas, single quotes, unquoted keys, and comments — with a fix for each.
Trailing comma
Unlike JavaScript, JSON does not allow a comma after the last item in an object or array.
Invalid:
{
"name": "Ada",
"role": "engineer",
}Fixed — remove the comma after the last value:
{
"name": "Ada",
"role": "engineer"
}Single quotes instead of double quotes
JSON strings and keys must use double quotes. Single quotes are valid in JavaScript object literals, which is the usual source of the mix-up, but JSON has no concept of them.
{'name': 'Ada'} // invalid
{"name": "Ada"} // validUnquoted object keys
Every key must be a double-quoted string — not a bare identifier.
{name: "Ada"} // invalid
{"name": "Ada"} // validComments aren't allowed
JSON has no comment syntax — not //, not /* */, not #. If you need comments, you're working with a JSON superset like JSON5 or JSONC, not JSON itself, and it needs to be stripped before it's valid JSON.
{
// invalid: comments break standard JSON parsers
"name": "Ada"
}Mismatched or missing brackets
Every { needs a matching }, and every [ needs a matching ]. This is the error that benefits most from a real parser instead of eyeballing it — a validator reports exactly where the structure breaks down instead of you counting braces.
Using JavaScript-only values
undefined, functions, and NaN/Infinity are all valid in a JavaScript object but have no JSON equivalent. The closest JSON has is null.
{"middleName": undefined} // invalid
{"middleName": null} // validOnce the syntax is valid, the next step is usually making it readable — see how to format (pretty-print) JSON.
Frequently Asked Questions
Why does my JSON fail to parse even though it looks fine?
The most common invisible culprits are a trailing comma after the last item, a stray comment, or single quotes instead of double quotes. Paste it into the JSON Validator — it points to the exact line and column, which is usually faster than scanning by eye.
Are single quotes ever valid in JSON?
No. The JSON spec (RFC 8259) requires double quotes for both strings and object keys. Single quotes are valid in JavaScript object literals, which is where the confusion usually comes from, but not in JSON.
Are comments allowed in JSON?
No — JSON has no comment syntax at all, not even // or #. Some tools (like JSONC or JSON5) extend JSON to allow comments, but that's a different, non-standard format.
Is a duplicate key a JSON error?
Technically no — the spec doesn't forbid it, and most parsers silently keep the last occurrence and discard earlier ones. That makes it a common source of confusing bugs even though it won't fail validation.