Verified Developer Solution • 100% OfflineFix "SyntaxError: Unexpected token o in JSON at position 1"
Understand and fix the common JavaScript error when calling JSON.parse() on an object instead of a string.
You are seeing `SyntaxError: Unexpected token o in JSON at position 1`. This happens when you call `JSON.parse()` on something that is already a JavaScript object (which gets coerced to the string `"[object Object]"`).
Check if your data is already parsed. If you are using `axios` or `fetch` with `.json()`, the response is already an object. Only use `JSON.parse()` on raw string data.
Code Standard: Bad Pattern vs Verified Fix
Live Syntax1// ❌ Bad: Parsing an already parsed object2const data = { name: "John" };3const parsed = JSON.parse(data); // Unexpected token o4 5// ✅ Good: Check type or rely on fetch's built-in parsing6const res = await fetch('/api/data');7const json = await res.json(); // json is already an object!Test and resolve this using JSON Formatter & Validator
Execute directly in your browser memory. Zero API keys, zero network tracking, completely client-side.
Frequently Asked Questions
Q:Why does it say position 1?
Because it converts the object to the string "[object Object]". The first character is "[", the second (position 1) is "o". JSON expects quotes.
Q:How can I validate my JSON string?
Use our JSON Formatter to paste your string and ensure it is valid JSON before parsing.