"[object Object]" is not valid JSON
By Santhi · Messages captured October 9, 2026 on 11 runtimes · How we test
JavaScript turns any plain object into the 15 characters [object Object] when it needs a string. If that string is then passed to JSON.parse, the parse fails. The data was lost at the moment it became a string, so there is nothing to repair; the fix is in the code that made the string.
What each runtime prints
We ran this input through JSON.parse in each browser and Node version, and through json.loads in Python. These are the messages exactly as printed.
[object Object]
| Runtime | Exact message |
|---|---|
| Chrome 151Node 24Node 22Node 20 | "[object Object]" is not valid JSON |
| Firefox 153 | JSON.parse: unexpected character at line 1 column 2 of the JSON data |
| Safari 26 (WebKit)Bun | JSON Parse error: Unexpected identifier "object" |
| Node 18 | Unexpected token o in JSON at position 1 |
| Python 3.13Python 3.12Python 3.10 | JSONDecodeError: Expecting value: line 1 column 2 (char 1) |
- Chrome and Node 20+ quote the whole text, so the message says exactly what was parsed.
- Firefox and Python point at column 2. The [ looks like the start of an array, so they fail at the o after it.
- Node 18 says "Unexpected token o in JSON at position 1", which is the same thing.
Edit it or paste your own. It runs in your browser; nothing is uploaded.
Common causes
- 1
localStorage or sessionStorage got an object
localStorage only stores strings. setItem('user', user) stores the text [object Object], and the JSON.parse when you read it back fails.
- 2
Parsing something that is already parsed
res.json() and axios response.data already give you an object. JSON.parse(data) converts it back to a string first, and that string is [object Object].
- 3
An object in a template string or concatenation
`${obj}` and "" + obj both give [object Object]. The same happens when an object is put in a URL, a header, a data- attribute or a form field.
- 4
Sending a request body without stringifying it
fetch(url, { body: data }) with a plain object sends [object Object]. The server's JSON parser then fails with this error.
How to fix it
Find where the object became a string and use JSON.stringify there.
JavaScript
// Saving
localStorage.setItem('user', JSON.stringify(user));
// Reading (getItem returns null when the key is missing)
const saved = JSON.parse(localStorage.getItem('user') ?? 'null');
// Sending
await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});Python
import json
# Python does not make "[object Object]"; it gets it from a JavaScript client.
# Log the raw body to see it:
raw = request.get_data(as_text=True)
print(repr(raw[:200]))
data = json.loads(raw)- Before calling JSON.parse, check what you have: typeof value === "string". If it is already an object, use it as it is.