Quick answer

JSON.parse() only accepts text. If you give it an object, JavaScript first turns the object into the text [object Object]. The parser reads [ (an array start), then hits the letter o at position 1 and stops. Fix: do not parse it. The value is already an object, so use it directly.

The same error in different browsers

Example that fails

const user = { name: "Ali" };
JSON.parse(user); // SyntaxError: Unexpected token o in JSON at position 1

The fix

const user = { name: "Ali" };
console.log(user.name); // already an object, no parsing needed

Common causes

1. Parsing the result of response.json()

response.json() already parses the body and returns an object.

const res = await fetch("/api/user");
const data = await res.json();   // object
// JSON.parse(data);             // wrong
console.log(data.name);          // correct

2. Axios and jQuery parse automatically

Axios puts the parsed body in response.data. jQuery with dataType: "json" also passes an object to the callback. Parsing it again causes this error.

3. Saving an object to localStorage without stringifying

localStorage stores strings only. Saving an object directly stores the text [object Object], and that text can never be parsed back.

// correct pair
localStorage.setItem("user", JSON.stringify(user));
const saved = JSON.parse(localStorage.getItem("user"));

If the bad value is already saved, remove it with localStorage.removeItem("user") and save it again.

How to check what you have

console.log(typeof value); // "object" means do not parse it
console.log(String(value)); // "[object Object]" confirms this error

If the value is a string that really contains JSON text, paste it into the JSON Formatter to find syntax mistakes, or the JSON Repair tool to fix them.

Have broken JSON right now?

Paste it into the free JSON Repair tool. It runs in your browser, so nothing is uploaded.

Open JSON Repair tool

FAQ

Why does the error say position 1?

Position counts from zero. The first character is [ at position 0 and the letter o of "object" is at position 1.

Can I just wrap JSON.parse in try/catch?

That hides the problem. First check typeof value. Only parse when it is a string.

Is my JSON uploaded when I use Parsekit tools?

No. The tools run in your browser and nothing you paste is sent to a server.

Related guides