Unexpected Token in JSON
An unexpected token error means the JSON parser encountered a character it didn't expect at a specific position. This is the most common JSON error and usually comes from trailing commas, single quotes instead of double quotes, unquoted property names, or comments in the JSON.
Why It Matters
The entire JSON document fails to parse. APIs return 400 errors, config files break, and applications crash at startup. A single misplaced character makes the whole document unreadable.
Common Causes
- Pasting a JavaScript object literal into a .json file, which carries over single quotes, unquoted keys, or a trailing comma.
- Leaving a // or /* */ comment in a config file that a strict JSON parser then rejects.
- A stray or missing character (an extra comma, a smart quote pasted from a document) sitting at the position the parser reports.
Code Examples
{
"name": "John",
"age": 30,
'email': "john@example.com",
"active": true,
}{
"name": "John",
"age": 30,
"email": "john@example.com",
"active": true
}How to Fix
- 1Replace single quotes with double quotes. JSON only allows double quotes for strings and keys.
- 2Remove trailing commas after the last property in objects and arrays.
- 3Wrap all property names in double quotes. Unquoted keys are valid in JavaScript but not in JSON.
- 4Remove comments. JSON does not support // or /* */ comments.
Frequently Asked Questions
What does the position or column number in the error mean?
Why does my JSON work in JavaScript but fail to parse?
How do I find the unexpected token quickly?
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorCloudways · Managed Cloud Hosting
Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).
Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303
Related JSON Errors
Trailing Comma in JSON
Fix the trailing comma error in JSON quickly. Unlike JavaScript, JSON forbids a comma after the last element, and our examples show you exactly how.
Single Quotes in JSON
JSON requires straight double quotes for every string and key, so single quotes always break parsing. Learn how to fix the single quotes error fast.
Unquoted Property Keys in JSON
JSON requires every property name wrapped in double quotes, so bare keys fail. Learn how to fix unquoted key errors when converting JavaScript objects.