Common JSON Syntax Errors (and How to Fix Each One)

JSON has a small, strict grammar, which is why a single stray character can make a whole document fail to parse with a vague message like Unexpected token. Below are the errors that break JSON most often, each with an example and a fix. Paste any of these into the jsonbloom editor and it will point to the exact line and column that failed.

Trailing comma

A comma after the last item is valid in JavaScript but not in JSON:

{ "a": 1, "b": 2, }   // invalid
{ "a": 1, "b": 2 }    // fix: remove the last comma

Missing or wrong quotes (single vs double)

JSON strings must use double quotes. Single quotes are not allowed:

{ 'name': 'Ada' }     // invalid
{ "name": "Ada" }     // fix: use double quotes

Unquoted keys

Every key must be a quoted string:

{ name: "Ada" }       // invalid (this is JavaScript)
{ "name": "Ada" }     // fix: quote the key

Unescaped special characters

Inside a string, double quotes, backslashes, and control characters must be escaped. A literal newline or an unescaped quote breaks the string:

{ "path": "C:\Users" }        // fix: escape the backslash
{ "quote": "She said \"hi\"" } // fix: escape inner quotes

Missing or mismatched brackets and braces

Every { needs a } and every [ needs a ]. When they do not match, the parser usually fails at the very end of the document. The status bar's line and column tell you where it gave up — count opening vs closing symbols from there.

Comments aren't allowed in JSON

{
  // the API key      <- invalid
  "key": "abc"
}

Remove comments, or use JSON5/JSONC if your tooling supports it.

Encoding & BOM issues

A file saved with a byte-order mark (BOM) or in a non-UTF-8 encoding can fail to parse even though it looks correct. Save the file as UTF-8 without BOM. NaN, Infinity, and undefined are also not valid JSON values — use a number, a string, or null instead.

How to validate JSON quickly

The fastest check is to paste it into a validator that reports the exact failure position. Drop your JSON into the jsonbloom editor: valid JSON renders as a graph, and invalid JSON shows the line, column, and reason so you can fix it in seconds.

Frequently asked questions

Why do I get "Unexpected token" when parsing JSON?

It means the parser hit a character it did not expect at that position — often a trailing comma, a single quote, an unquoted key, or a missing bracket. The editor shows the exact line and column so you can jump to it.

Are comments allowed in JSON?

No. Standard JSON (RFC 8259) does not allow // or /* */ comments. Remove them, or use a superset like JSON5 or JSONC in tools that support it.

Can JSON keys be unquoted?

No. Every key in JSON must be a double-quoted string. { name: "Ada" } is JavaScript, not JSON.

Try it now

Paste your JSON into the editor and see the structure as an interactive graph — free, in your browser.

Open the jsonbloom editor →