Unexpected token in JSON usually means the parser tripped on one bad character.

The wording sounds vague, but the pattern is predictable. The parser expected a valid JSON token and found something else instead. That can be a stray opening character, a missing comma, an unquoted key, or invalid quotes.

4 min readValidator / Formatter
TL;DRRead the reported token and location, inspect the punctuation just before it, fix the smallest obvious syntax problem, then validate again before touching anything else.

What the error usually means

The parser expected one valid JSON token and found something else instead. That unexpected character might be the real mistake, or it might be where the parser finally noticed an earlier problem.

If the message says unexpected token at position 0, start by checking the very first character of the payload.

Broken patterns that trigger it

Invalid starting character

JSON must start with a valid JSON value. A stray leading character breaks parsing immediately.

Missing comma between properties

The parser reaches the next key and realizes the comma between siblings never happened.

Malformed key or invalid quotes

Unquoted keys and invalid quote characters both show up as unexpected token failures.

Position 0 is its own clue

If the error points to position 0, the parser is unhappy with the very first character of the payload.

That often means you are not looking at JSON at all. It could be HTML, a JavaScript object literal, a stray letter, or a response body that starts with some other format.

Position 0 often means the whole payload type is wrong. Before you hunt for missing commas, check whether the response body actually starts with {, [, ", a number, true, false, or null.

How to find the real cause

  1. 1Read the unexpected token message and note the reported position or line.
  2. 2Look just before that location for a missing comma, colon, quote, or bracket.
  3. 3Check the start of the payload if the error mentions position 0.
  4. 4Validate again after the fix and then format the corrected JSON.

Quick answers

What to do next

Start with the right tool now, then move back to the hub or sideways into the adjacent guides if the first answer was not the whole fix.