How browsers word it
| Chrome and Node (V8) | Unexpected non-whitespace character after JSON at position 8 (line 1 column 9) |
|---|---|
| Chrome and Node, older | Unexpected token { in JSON at position 8 |
| Firefox | JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 9 of the JSON data |
| Safari | JSON Parse error: Unexpected content after JSON |
Common causes
Two values in a row
Joining two JSON texts gives something that is no longer one JSON document.
Input
{"a": 1} {"b": 2}JSON Formatter says
Unexpected "{" after the end of the JSON valueOne object per line (NDJSON)
Log files and streaming APIs often write one JSON object per line. Each line is valid JSON on its own, but the whole file is not.
Input
{"a": 1} {"b": 2}JSON Formatter says
Unexpected "{" after the end of the JSON valueA stray character at the end
A leftover character, a second closing bracket or a pasted prompt sign can follow the value.
Input
{"a": 1}xJSON Formatter says
Unexpected "x" after the end of the JSON value
Two arrays
Pasting two lists one after the other has the same problem.
Input
[1, 2] [3]
JSON Formatter says
Unexpected "[" after the end of the JSON value
How to fix it
- For one object per line, split the text on newlines and parse each non-empty line on its own.
- To keep everything in one document, wrap the values in an array and separate them with commas.
- Remove a stray character after the final closing brace or bracket.
- Paste the text into the JSON formatter to see where the first value ends.