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 Doctor

Quick 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 ShapeLikely CauseFirst Check
Unexpected token }Trailing comma or missing valueCharacter before }
`Unexpected token '``Single quotesUse double quotes in JSON
Unexpected token oParsing an object againCheck the value type
Unexpected token <HTML returned instead of JSONResponse status and body

Practical Workflow

  1. Copy the exact input passed to JSON.parse() or response.json().
  2. Paste it into JSON Error Doctor.
  3. Check the token and position.
  4. If it came from an API, inspect status code, Content-Type, and response body.
  5. 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