Unexpected Token o in JSON – Causes and Fixes

Local only

Unexpected token o often appears when JSON.parse receives a JavaScript object instead of JSON text. The object is coerced to [object Object], which is not valid JSON.

Indent

15 chars · 1 line

Two-way sync · Edit either side and the other updates automatically.

Invalid JSONExpected a JSON value
Line 1Column 2Character 2Found “o”
[object Object]

JSON.parse runtime error

Why JSON.parse can fail with Unexpected token o

This error commonly means the value passed to JSON.parse is already a JavaScript object. Converting that object to text implicitly produces [object Object], so parsing stops at the first o instead of reading JSON syntax. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Browser-local JSON processing
  • Route-specific malformed JSON example
  • Focused parser or repair guidance
  • Broken and corrected JSON example
  • Related JSON problem navigation

Steps

  1. Inspect the actual value passed to JSON.parse and log typeof value.
  2. If it is already an object or array, use it directly instead of parsing it again.
  3. If it should be text, inspect the raw response and validate that text separately.

Double parsing is the usual cause

JSON.parse expects a string containing JSON text. Passing an object can lead to string coercion before parsing, producing text such as [object Object] that is invalid from the first character.

  • An HTTP client already decoded the JSON response.
  • A state or storage layer already holds an object.
  • Code calls JSON.parse on a value that was parsed earlier.

Check the runtime type before editing the payload

If typeof value is object, fixing commas or quotes cannot solve the real problem. Remove the extra JSON.parse call or stringify only when you intentionally need JSON text.

Unexpected token o example

The invalid text below represents what an object can become when coerced to a string before parsing.

Value reaching the parser

[object Object]

Valid JSON text

{"name":"Ada","active":true}

Common questions

Frequently asked questions

Why does Unexpected token o often mention JSON.parse?

Because an object can be coerced to the string [object Object], and the o in object is not valid where JSON syntax is expected.

Should I stringify the object and parse it again?

Usually no. If the value is already the object you need, use it directly. Stringify only when another part of the application specifically needs JSON text.

How do I confirm double parsing?

Inspect typeof value and the raw value immediately before JSON.parse. An object or array at that point indicates the parser is unnecessary.

Debugging a specific JSON issue? Browse JSON troubleshooting.