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.
Related JSON guides
How to Fix Invalid JSON: A Practical Error-Checking Guide
Find the first JSON syntax error, understand common parser messages, and fix invalid JSON without changing valid data.
How to Fix a Trailing Comma Error in JSON
Learn why trailing commas make JSON invalid, how to find the exact error, and how to fix it safely.
JSON Quotes and Escape Characters: Common Mistakes and Fixes
Use double quotes correctly in JSON and escape quotes, backslashes, line breaks, and control characters without corrupting text.