ERROR - Updated 2026-05-15
JSON Unexpected token Error
How to debug JSON Unexpected token errors by checking the token, position, quotes, commas, and real API response body.
Open JSON Error DoctorQuick Answer
JSON Unexpected token means the parser found a character that is not valid at that point in JSON. The problem may be a trailing comma, single quotes, a missing brace, an already-parsed object, or an API response that is not JSON at all. Check the token and position first, then inspect the exact string being parsed.
Why This Matters
JSON parse errors often appear in front-end code, API integrations, webhooks, and configuration files. The error message can feel vague, but the token and position usually point to a small area. Guessing without checking the real response body wastes time.
Common Causes
| Error Shape | Likely Cause | First Check |
|---|---|---|
Unexpected token } | Trailing comma or missing value | Character before } |
| `Unexpected token '`` | Single quotes | Use double quotes in JSON |
Unexpected token o | Parsing an object again | Check the value type |
Unexpected token < | HTML returned instead of JSON | Response status and body |
Practical Workflow
- Copy the exact input passed to
JSON.parse()orresponse.json(). - Paste it into JSON Error Doctor.
- Check the token and position.
- If it came from an API, inspect status code, Content-Type, and response body.
- Fix syntax only after confirming the response is actually JSON.
Example
Invalid JSON:
{
"name": "Alice",
}
Valid JSON:
{
"name": "Alice"
}
The trailing comma is legal in some JavaScript object literals, but not in JSON.
Common Mistakes
- Copying a console object instead of the real response text.
- Calling
JSON.parse()on data that is already an object. - Fixing JSON syntax while the API is returning an HTML login page.
- Ignoring the position number in the error message.
Related Tool
Related Article
Updated
2026-05-15