Troubleshooting · Guide

Common JSON Validation Errors and How to Fix Them

Why is my JSON invalid?

SHORT ANSWER

Almost all invalid JSON comes from a small set of mistakes: trailing commas, unquoted or single-quoted keys, missing commas, mismatched or missing brackets, and stray control characters. JSON is strict by design, so one misplaced character anywhere makes the whole document invalid. A validator that reports the line and column turns each case into a quick fix.

Trailing commas

{"a":1,"b":2,} is invalid. JSON does not allow a comma after the last item, so remove the final comma. This is the most common mistake because many languages permit it.

Unquoted or single-quoted keys

Both {name:"Alice"} and {'name':'Alice'} are invalid. JSON requires double-quoted keys and double-quoted string values.

Missing commas

An object where values are separated by whitespace or a newline instead of a comma fails validation. Every key-value pair must be followed by a comma except the last one.

Mismatched brackets

An opening brace or bracket closed with the wrong character fails at parse time. Count the nesting; a validator points at the offending character so you can find the imbalance.

Comments are not allowed

// and /* */ are invalid in strict JSON. Use a JSONC-capable parser or strip comments before validation. JSON5 and YAML allow comments, but the JSON standard does not.

Duplicate keys and number formats

Duplicate keys such as {"a":1,"a":2} are technically valid, but most parsers keep the last value, which hides bugs. Watch for leading zeros, because 01 is invalid while 1 is fine, and for bare values such as undefined, which are not JSON at all.

TRY IT LOCALLY

Try it in your browser with our JSON Validator. No upload, no server.

Open JSON Validator →

FAQ

Why does one tiny comma break all my JSON?

JSON parsers require exact syntax. There is no lenient mode in the standard, so a single stray character anywhere invalidates the whole document.

Can I have comments in JSON?

Not in strict JSON. Some tools and languages support JSONC with comments or JSON5, but standard parsers reject comments.

Are duplicate keys allowed?

The spec allows them, but most parsers silently keep the last value, which can hide bugs. Avoid them.

Why do leading zeros break JSON?

JSON numbers cannot have leading zeros. 01 is invalid, so write 1.