JSON Unexpected Token Error
Unexpected token is one of the most common JSON errors. It usually means the parser hit a character or symbol it did not expect at the current position.
Common causes
- Missing or extra comma between properties.
- Trailing comma after the last array or object element.
- Single quotes instead of double quotes for strings.
- Unescaped special character inside a string.
How to fix
- Run your JSON through an online validator to get the exact line and column.
- Use double quotes for all keys and string values.
- Remove trailing commas and ensure commas only between elements.
- Escape backslashes and quotes inside strings.
Examples
Bad
{"a": 1, "b": 2,}Good
{"a": 1, "b": 2}FAQ
- What does unexpected token mean in JSON?
- The parser encountered a character it did not expect at that position, often a comma, quote, or bracket issue.
- How do I find the unexpected token?
- Use a JSON validator; it will report the line and column of the error.
Fix it now
Try in validator (prefill this example)