How to Fix Unexpected Token Errors in JSON

5 min read · Updated 2026-07-18

An unexpected token message means the parser found a character that cannot appear at that point in a JSON document. The token is a clue, but the correction often belongs immediately before it.

Read the token in context

If the parser reports an unexpected closing brace, look for a trailing comma before it. If it reports an unexpected letter, check whether a property name or text value is missing double quotes.

Look for missing punctuation

JSON needs a comma between sibling properties and a colon between an object key and its value. A missing delimiter commonly makes the next valid character look unexpected.

{
  "first": 1,
  "second": 2
}

Avoid JavaScript-only syntax

Comments, single-quoted strings, undefined, NaN, and trailing commas can be valid JavaScript syntax but are not valid JSON. Replace them with JSON values and double-quoted strings.

Frequently asked questions

Does unexpected token always identify the bad character?

It identifies where parsing stopped. The actual cause can be the previous comma, quote, colon, or missing closing character.

Can comments appear in JSON?

No. Standard JSON has no comment syntax. Remove comments or store the explanation in a normal string field.