August 13, 2026

Unexpected Token Error in JSON

Unexpected Token Error in JSON

If you've ever tried to parse JSON, you've likely seen this error: SyntaxError: Unexpected token o in JSON at position 1

What does it mean?

This error means the parser encountered a character it did not expect while trying to read your JSON string.

The infamous 'token o'

The most common variation is Unexpected token o. This almost always happens when you try to run JSON.parse() on something that is already a JavaScript object.

When you do JSON.parse(myObject), JavaScript coerces the object to a string, resulting in "[object Object]". The parser sees the o (the first character of "object") and throws an error because JSON must start with { or [.

How to fix it

  1. Ensure the data you are parsing is actually a string.
  2. If the token is a single quote ', you are likely using single quotes instead of double quotes for your keys/values.
  3. Use a JSON Validator to identify the exact syntax error.