JSON Validator

Check JSON syntax and find the exact position of any error.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What the JSON Validator does

The JSON Validator answers one question: is this valid JSON according to RFC 8259? If it is, it tells you what the root value is, such as an object or an array of 25 items. If it is not, it shows the line and column of the first problem and says when the input looks cut off.

Using the JSON Validator

  • Minify gives compact output and Validate checks without rewriting.

JSON Validator examples

The built-in sample

Input

{"name":"Ada Lovelace","active":true,"tags":["math","code"],"address":{"city":"London"}}

Output

Valid JSON. The root is a(n) object.

This is the input that the Load sample button fills in.

A top-level value does not have to be an object

Input

[1, 2, 3]

Output

Valid JSON. The root is an array of 3 items.

RFC 8259 allows any JSON value at the top level. The validator reports what the root is, which is a quick way to notice that an endpoint returned an array where you expected an object.

Each output was produced by running this tool on the input above it.

How it works

This tool follows RFC 8259, the IETF standard for JSON. Your text is parsed with the browser's native JSON parser inside a Web Worker, so large documents do not freeze the page. RFC 8259 allows six value types (object, array, string, number, true/false and null), requires double-quoted keys and strings, and forbids comments and trailing commas. If the text is not valid, the tool reports the line and column of the first problem and tells you when the input looks truncated.

Line-delimited JSON (NDJSON, one JSON value per line) is detected automatically. Each record is checked on its own, and an error names the exact line of the bad record.

Input problemWhat the tool tells you
Missing closing brace or bracketInput looks truncated, with the line and column where it ended
Single quotes or unquoted keysUnexpected token, with line and column
Trailing comma or commentUnexpected token at the first offending character
Bad line in NDJSONNDJSON record error with the line number

Details and limits

  • The check is syntax only. It does not know which keys or types your application expects; for that you need a schema, which you can draft with JSON to JSON Schema.
  • A duplicate key is not reported. RFC 8259 only says that keys "should" be unique, and the browser parser accepts the document and keeps the last value.
  • A file that starts with a byte-order mark fails at line 1, column 1: the mark is not whitespace in JSON. Save the file as UTF-8 without BOM.
  • Very large exponents such as 1e999 pass, because the grammar allows them, even though no 64-bit number can hold the value.

Common errors

Message or symptomWhat it means
Unexpected token or "Expected property name"Keys and strings must use double quotes, and comments are not allowed in JSON.
Unexpected token near the end of an object or arrayA trailing comma after the last item. Remove it.
The input looks truncatedA closing brace, bracket or quote is missing, often from copying part of a log line.
Unexpected token N, u or INaN, undefined and Infinity are JavaScript values, not JSON. Use null or a number.

Questions

What does "The input looks truncated" mean?

The text ends before the JSON is complete: a closing brace, bracket or quote is missing. This usually happens when part of a log line or a cut-off response was copied.

Is a single number or string valid JSON?

Yes. Since RFC 7159, and in the current RFC 8259, any JSON value may stand at the top level, not only an object or an array.