How to fix JSON parse errors
Every common parser message, translated into what is actually wrong — and what to change.
Frequently asked questions
What does "Unexpected token } in JSON at position 42" mean?
The parser reached a closing brace where it needed something else — almost always because of a trailing comma before it. Position 42 is a character offset from the start of the document, which is why it is so unhelpful in anything larger than a few lines.
What does "Unexpected end of JSON input" mean?
The document ended while a structure was still open — a missing closing brace or bracket, or a truncated copy-paste. It also happens when JSON.parse receives an empty string, which is the usual cause when the value came from an empty HTTP response body.
Why does "Unexpected token < in JSON at position 0" happen?
You are parsing HTML, not JSON. The response was almost certainly an error page — a 404, a 500, or a login redirect — served as HTML while your code assumed JSON. Check the response status and content-type before parsing, and log the first hundred characters of the body when it fails.
Can JSON have comments?
No. Any conforming parser rejects both // and /* */. Some ecosystems use JSONC (VS Code settings files) or JSON5, which do allow them, but a file with comments is not portable JSON. If it must be consumed generally, move the explanation into a "_comment" property or into documentation.
Why did my large ID number change value?
JavaScript parses JSON numbers as IEEE 754 doubles, so integers above 9007199254740991 lose precision — Twitter IDs, Snowflake IDs and database bigints are all in this range. This is not a parser bug and every JavaScript-based tool has it. Transmit large identifiers as strings.
Found a mistake on this page? Tell me — a page that is confidently wrong is worse than no page.