Common causes
1. A string value without double quotes
Every string in JSON must be wrapped in double quotes. A bare word such as active, yes or pending is read as an unknown token; only true, false and null may appear unquoted.
{"id": 1042, "status": active}{"id": 1042, "status": "active"}2. Single quotes or a JavaScript object literal
Text copied from JavaScript or Python source often uses single quotes or unquoted keys. JSON accepts neither; see single quotes in JSON for the full story.
{'id': 1042, status: 'active'}{"id": 1042, "status": "active"}3. Number spellings JSON does not allow
JSON numbers cannot start with + or ., cannot have leading zeros and cannot be hexadecimal. Write plain decimal digits, or quote the value if it is really an identifier.
{"offset": +5, "ratio": .75, "mask": 0xFF, "zip": 02139}{"offset": 5, "ratio": 0.75, "mask": 255, "zip": "02139"}4. The text is not JSON at all (position 0)
When the bad token is at position 0, the whole body is something else: plain text such as Internal Server Error, an HTML page (see Unexpected token ‘<’) or an empty string. Log the raw response before parsing it.
Internal Server Error{"error": "Internal Server Error", "status": 500}Frequently asked questions
What does "position 0" mean in this error?
Positions count characters from the start of the text, starting at 0. Position 0 means the very first character was already wrong, so the input is probably not JSON at all, for example an HTML error page, plain text or the word undefined.
How do I find position 1234 in a large file?
Paste the text into PasteKit: it reports the line and column instead of a raw offset and highlights the spot. Newer Chrome and Node versions also print “(line X column Y)” after the position.
Why does the same text work in my JavaScript code?
JavaScript object literals are more permissive than JSON: they allow single quotes, unquoted keys, trailing commas and comments. JSON.parse only accepts the strict JSON grammar.
Can PasteKit repair the input automatically?
Yes. Fix it handles unquoted strings and keys, single quotes, trailing commas, comments and Python literals, and shows a diff of every change before you accept it.