JSON Validator

Paste or upload JSON to check it is valid and pin the first error. Runs in your browser.

Pasted text and chosen files stay on this device. Nothing is sent to a server.

Drop a file here, choose one, or paste.

No output yet Validate to see the result here.

How to use it

  1. 1

    Paste the text.

  2. 2

    If it is invalid, the reported position is where parsing stopped — the mistake is usually there or just before it.

What it does

A validator answers one question — is this valid — and the useful version answers a second one: if not, where does it stop being valid. A bare "invalid" sends the reader back to reading the whole file.

Parse the input and report valid, or the first error with its offset, line and column, plus a short excerpt around the position.

Why it works this way

JSON has one grammar and no extensions. A validator that accepts a superset is reporting on a language nobody else speaks, so the answer would not transfer to the system that rejected the payload.

Only the FIRST error is reported, deliberately. Later errors are usually consequences of the first, and a list of ten often means one mistake.

The line and column are what make the answer usable on a document of any size; a character offset alone is not, because nobody counts characters.

Examples

{"a": 1}
valid
the smallest valid document with content
{
  "a": 1,
  "b": 2
  "c": 3
}
invalid at line 4 column 3: expected , or } after the value
a missing comma is reported at the next token, which is where the parser found out

Inputs and outputs

  • JSON text
  • valid / invalid
  • the first error, with line and column
  • an excerpt of the text around the error

Edge cases

  • trailing comma
  • single quotes
  • unquoted keys
  • NaN and Infinity — not JSON numbers
  • duplicate keys — valid, last wins, worth a warning rather than an error

Frequently asked questions

Is a duplicate key an error?

No. The grammar allows it and the last value wins. It is usually a mistake, so it is worth knowing about, but it is not invalid.

Why only the first error?

Later errors are usually the same mistake seen again. Fixing the first and re-validating is faster than reading a list.

Related tools

Sources

  • RFC 8259, section 2 (grammar)