JSON Forge
100% Client-Side: your data is never sent to a server

JSON errors

Unexpected non-whitespace character after JSON

The JSON below reproduces this error. See where it breaks, press Fix JSON, or paste your own text.

Loading editor…
Paste or type JSON on the left to explore it as a tree.
Empty🔒 Processed locally in your browser

What the error means

The parser read one complete JSON value successfully and then found more text after it. A JSON document may contain exactly one top-level value, optionally surrounded by whitespace, so anything after it is an error.

The message looks like this in Chrome, Edge and Node.js (Firefox and Safari use different wording for the same problems):

Unexpected non-whitespace character after JSON at position 7 (line 1 column 8)
Unexpected non-whitespace character after JSON at position 8 (line 1 column 9)

Common causes

Several JSON documents in one text

Two objects side by side, or one per line (JSON Lines or NDJSON), are not one JSON document. This is the usual cause for log files and streaming exports.

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

An extra closing brace or bracket

One closing character too many, often after editing by hand. The position points at the extra character.

Broken:  {"a": 1}}
Valid:   {"a": 1}

Trailing text after the JSON

A semicolon from a JavaScript file (such as module.exports = {...};), a log timestamp, or a leftover line break with text. Cut everything after the final closing brace.

How to find the problem

  1. Paste the text that you passed to JSON.parse into the editor above. The status bar shows the line and column of the first problem, and Go to error jumps there.
  2. Remember that the position in the message is where the parser gave up, which is often one token after the real mistake. Look at the character before it as well.
  3. If the text came from a request, log the raw response text before parsing it. In the browser, open the Network tab, select the request and read the Response tab.

Parse JSON Lines one line at a time

const records = text
  .split("\n")
  .filter((line) => line.trim() !== "")
  .map((line) => JSON.parse(line));

Frequently asked questions

How do I view a JSON Lines file here?

Paste one line at a time, or wrap all lines in square brackets and separate them with commas to turn them into a single array.

Is there a way to parse the first value and ignore the rest?

Not with JSON.parse. Cut the text at the end of the first value, or use a streaming parser that can read several values from one stream.

Related errors

All common JSON errors · JSON Validator