The exact message
{"id": 1, "event": "signup"}
{"id": 2, "event": "login"}- Chrome, Edge, Node.js
SyntaxError: Unexpected non-whitespace character after JSON at position 29 (line 2 column 1)- Firefox
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data- Safari
SyntaxError: JSON Parse error: Unable to parse JSON string
} too many{"a": 1}}- Chrome, Edge, Node.js
SyntaxError: Unexpected non-whitespace character after JSON at position 8 (line 1 column 9)- Firefox
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 9 of the JSON data- Safari
SyntaxError: JSON Parse error: Unable to parse JSON string
{"a": 1};- Chrome, Edge, Node.js
SyntaxError: Unexpected non-whitespace character after JSON at position 8 (line 1 column 9)- Firefox
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 9 of the JSON data- Safari
SyntaxError: JSON Parse error: Unable to parse JSON string
Measured in Chrome 158, Firefox 159, Safari's engine (WebKit 27.2) and Node.js 22. Edge uses the same engine as Chrome.
The message says “non-whitespace” because spaces, tabs and line breaks after the JSON are fine; anything else isn't. Safari's “Unable to parse JSON string” doesn't say where.
What it means
The text starts with a complete JSON value, and then there's more. A JSON document is exactly one value: one object, one array, one string or number. The position points at the first character after it.
What causes it
- JSON Lines (NDJSON): one JSON object per line, used for logs, data exports and streaming APIs. Each line is valid JSON; the whole file isn't one document.
- Two documents glued together: chunks of a streamed response appended to each other, or a server that writes the body twice.
- An extra closing bracket, left over after editing by hand:
{"a": 1}}. - JavaScript around the JSON: the
;ofconst data = {…};, or a comment after it. - Other output after the JSON, when a script prints a log message after the data it was asked for.
How to find the spot
The position is the first extra character. In the example, line 2 column 1 is the start of the second record. The JSON Formatter shows the same spot and says there's “unexpected extra content after the JSON value”; Show me jumps there, so you can see what follows.
How to fix it
For JSON Lines, parse each line on its own:
const records = text
.split("\n")
.filter((line) => line.trim() !== "")
.map((line) => JSON.parse(line));
If you need one JSON document instead, turn the records into an array: [ before the first, a comma after each one
except the last, ] at the end. That's the fixed version in the example below.
For a stray } or ; or a comment, delete it. Fix it isn't offered for this error: text after the JSON could be a
second document, a typo or something else entirely, and it never guesses.
Worked example
Two records in JSON Lines format, read as one document:
The input
{"id": 1, "event": "signup"}
{"id": 2, "event": "login"}- Chrome and Node.js say
SyntaxError: Unexpected non-whitespace character after JSON at position 29 (line 2 column 1)- The JSON Formatter says
- Hmm, something's off on line 2, column 1: unexpected extra content after the JSON value 🤔
Fix it isn't offered here. Fixed by hand:
[
{"id": 1, "event": "signup"},
{"id": 2, "event": "login"}
]