Unexpected token in JSON

This error appears when a JSON parser reaches a character or syntax pattern it does not expect. The problem is usually close to the reported token, even if the real mistake started slightly earlier in the string.

Broken example

{ name: "Ada" }

Corrected example

{ "name": "Ada" }

Why this error happens

JSON is strict. Object keys must be in double quotes, strings must use double quotes, and comments are not allowed. When a parser sees something like name without quotes, it throws an unexpected token error.

How to fix it

  1. Look near the character or token mentioned in the error.
  2. Check for single quotes, comments, missing quotes, or a trailing comma.
  3. Validate the repaired payload again.
  4. Format the fixed JSON so the structure is easier to read.

FAQ

Is the unexpected token always the real problem?

Not always. It is often where the parser first notices something wrong, which may be shortly after the original mistake.

Can comments cause this?

Yes. Comments are not valid JSON and often trigger unexpected token errors.

Will formatting fix the issue automatically?

No. The JSON must be valid before it can be formatted.

What tool should I use first?

Start with JSON Validator.