Unexpected non-whitespace character after JSON data
JSON.parse() finished a complete value and then found more non-space characters. It is the JavaScript twin of Python's "Extra data": you most likely have two JSON values concatenated or JSON Lines being parsed as one string. Split the input and parse each value separately.
Runs entirely in your browser — no upload. It isolates the extra-data-after-JSON cause (concatenated payloads or NDJSON) and shows exactly where the second value starts, unlike a generic validator.
How to fix "Unexpected non-whitespace character after JSON data"
- Look for a second value after the first. The parser finished one complete JSON value, then found more non-space text. This means two JSON documents are glued together (e.g. }{ or }\n{), or trailing junk follows the payload. Paste it into the tool above to see where the extra data begins.
- Split NDJSON line by line. If the source is newline-delimited JSON (one object per line), do not JSON.parse() the whole blob. Split on \n and parse each line separately.
- Trim trailing bytes. If a stray character, BOM, or duplicated response body follows the JSON, remove it at the source — a misbehaving API or a double-write is usually to blame.
What the error means
Newer V8 (Node 20+, modern Chrome) reports trailing content with this message instead of the old generic "Unexpected token". The JSON up to that point was valid; there is simply extra data after it.
The common causes
1. JSON Lines / NDJSON. Split on newlines and parse each line: text.trim().split('\n').map(l => JSON.parse(l)).
2. Concatenated responses. Two payloads joined into one string. Separate them before parsing, or decode incrementally.
3. Duplicated or appended output. A logging step or a retried write doubled the body. Keep only the first complete value.
Fix it fast
This is a structural problem, not a typo, so the repair tool above only validates a single value at a time — paste one object to confirm it parses, then handle the multiple values in code by splitting the input.
FAQ
Why did I only start seeing this error recently?
V8 changed the wording. Older Node/Chrome said "Unexpected token" for the same trailing-data problem; Node 20+ says "Unexpected non-whitespace character after JSON data".
How do I parse NDJSON in JavaScript?
Split on newlines and map JSON.parse over the non-empty lines: text.trim().split('\n').filter(Boolean).map(l => JSON.parse(l)).
Is a trailing newline a problem?
No — whitespace after the value is allowed. Only non-whitespace characters after the first complete value trigger this error.