json

FormatValidateConvert

Unexpected non-whitespace character after JSON

The parser finished reading a complete JSON value and then met another character that was not a space, tab or line break. The first value may be perfectly valid; the problem is the text following it. JSON describes one value per document, so putting two objects next to each other does not make one larger document. A closing brace followed immediately by another opening brace is a common sign that two successful responses were joined together before either was parsed.

Two documents glued together

Input

{"a":1}{"b":2}

Do

  1. Paste the input into the validator.
  2. Press Repair in the editor band.

Result

Wrapped multiple top-level values in an array

[{"a":1},{"b":2}]

Try it in the validator →

What each runtime prints for this input
RuntimeMessage
Chrome 153 · Node.js 26Unexpected non-whitespace character after JSON at position 7 (line 1 column 8)
Node.js 18 (older V8)Unexpected token { in JSON at position 7
Firefox 156JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 8 of the JSON data
Safari 26JSON Parse error: Unable to parse JSON string
Python 3.14 jsonExtra data: line 1 column 8 (char 7)
This siteUnexpected "{" after the end of the JSON valueline 1, column 8

Recorded from each runtime; the wording is in Firefox’s, Safari’s and Python’s sources.

In this input the first object ends at position 6, and the second begins at position 7, which Chrome reports as line 1, column 8. The offset counts from zero; the column counts from one. Moving to column 7 would land on the closing brace of the valid object rather than the unexpected opening brace. Whitespace between the objects would only move the reported position: it would not make the pair valid JSON.

Check the code that assembled the text, particularly an append operation on a file or an accumulator reused between requests. Each write may have produced a valid document independently, while the final buffer contains their concatenation. If both records belong together, put them in an array with a comma between them. If they represent separate responses, keep their boundaries and parse each response separately instead of silently changing the data's shape.

A newline is not a document boundary for JSON.parse

NDJSON, short for newline-delimited JSON, stores a complete JSON record on each line. It is useful for streams and log files, but the entire file is not a single JSON document. Calling JSON.parse on the whole body reads the first record and then fails at the start of the next one. A download ending in .jsonl often follows the same convention. Confirm the format with the producer before treating the extra line as corrupt data.

Read a known NDJSON file one record at a time, using each complete line as the parser's input. That approach depends on the file actually being newline-delimited: ordinary, nicely indented JSON spreads one object over several lines and cannot be split this way. Network chunks are different again, since a chunk boundary may fall halfway through a record. Keep the unfinished line until the next chunk arrives, rather than attempting to decode every chunk as an independent document.

A status word after the JSON

Input

{"id": 7} done

Do

  1. Paste the input into the validator.
  2. Press Repair in the editor band.

Result

Nothing here could be repaired automatically.

Try it in the validator →

What each runtime prints for this input
RuntimeMessage
Chrome 153 · Node.js 26Unexpected non-whitespace character after JSON at position 10 (line 1 column 11)
Node.js 18 (older V8)Unexpected token d in JSON at position 10
Firefox 156JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 11 of the JSON data
Safari 26JSON Parse error: Unable to parse JSON string
Python 3.14 jsonExtra data: line 1 column 11 (char 10)
This siteUnexpected "done" after the end of the JSON valueline 1, column 11

Recorded from each runtime; the wording is in Firefox’s, Safari’s and Python’s sources.

Here the object is followed by a space and the word done. Chrome points to position 10, line 1, column 11, where the letter d starts. This often happens when a command prints its data and its progress messages to the same output stream. It can also come from a response template that adds a diagnostic line after serialising an object. Inspect the final characters of the raw body, not just its opening preview, since the valid beginning can hide the unwanted suffix.

Send progress and debug messages to a separate destination, such as a command's standard error stream, and reserve the data stream for the JSON. When a response includes several kinds of information intentionally, encode them as properties of one object. Trimming spaces alone cannot remove a log message, and taking everything before the last brace is unreliable when strings contain braces or several records are present.

Different words for the same extra text

Modern V8, used by Chrome and Node.js, explicitly says the character came after JSON. Node.js 18 predates the more specific wording and instead names the unexpected brace or letter at its offset. Firefox mentions extra non-whitespace after JSON data and supplies a line and column. Python calls the suffix Extra data, while Safari's recorded message only says it was unable to parse the JSON string. The tables use identical inputs, so those different descriptions do not imply different faults. For a failure before a complete value ends, compareUnexpected end of JSON input.

Choosing the correction here

Open either example in the JSON Validatorto see the first character after the finished value underlined. This site's parser describes that boundary directly and quotes what followed it. Repair wraps the two adjacent objects in an array, preserving both values but changing the document's outer type. It leaves the object followed by done alone: discarding a suffix would be a guess about which text matters. Compare the result with the format your consumer expects, and useFix invalid JSONfor an example of reviewing several repair choices together.