Developer Guide
JSON Parse Error: Unexpected Token
Fix "Unexpected token" JSON parse errors. Learn common causes: trailing commas, single quotes, unquoted keys, and how to validate your JSON.
The "Unexpected token" error in JSON.parse() means your JSON has invalid syntax. This guide covers the most common causes and how to fix them quickly.
Trailing commas
JSON does not allow trailing commas after the last item in an array or object. {"name": "Alice",} is invalid. Remove the comma before the closing brace or bracket. JavaScript allows trailing commas, but JSON does not — this is the most common surprise.
Single quotes instead of double quotes
JSON requires double quotes for all strings and keys. {'name': 'Alice'} is invalid. Use {"name": "Alice"}. If you pasted from JavaScript, replace single quotes with double quotes.
Unquoted keys
JSON keys must be quoted strings. {name: "Alice"} is invalid. Use {"name": "Alice"}. JavaScript object literals allow unquoted keys, but JSON does not.
Comments in JSON
Standard JSON does not support comments. // comment or /* comment */ will cause parse errors. Remove all comments or use JSONC (JSON with Comments) for config files that your tooling supports.
How to debug
Paste your JSON into the JSON Formatter. It reports the exact line and column of the error. Fix one error at a time — the first error often causes cascading errors later in the file.
Summary
Use the JSON Formatter to validate and find the exact location of your syntax error. Once fixed, JSON.parse() will work correctly.