Home / Developer tools / JSON validator

JSON Validator

Check whether your JSON is valid. If it is not, you get the line and column of the first error and a plain explanation of what to fix.

Try:

The work is done in your browser. Your JSON is not sent to any server.

What is checked

The validator uses the strict JSON rules of the standard (RFC 8259, the same as ECMA-404). That is what JSON.parse in a browser, json.loads in Python and most APIs accept. It reports the first error with its line, column and a short message, and shows the line with a marker under the problem.

Warnings for valid JSON

Some JSON is valid but still causes trouble. The validator warns you about:

  • Duplicate keys. The standard allows them, but parsers keep only one value, usually the last, and the others are lost silently.
  • Numbers that lose precision. An integer with more than 15 digits, such as an order ID, cannot be held exactly by a JavaScript number. Store such IDs as strings.
  • Numbers out of range. A value such as 1e999 becomes Infinity in many languages.

The most common JSON errors

MistakeExampleFix
Trailing comma{"a": 1,}Remove the last comma
Single quotes{'a': 1}Use double quotes
Unquoted key{a: 1}Write "a"
Comment// noteRemove it; JSON has no comments
Missing comma{"a": 1 "b": 2}Add a comma between the pairs
NaN, Infinity, undefined{"a": NaN}Use null or a string
Leading zero or plus sign{"a": 007}Write 7
Raw line break in a string"line 1[Enter]line 2"Write \n instead
Several documents{"a":1}{"a":2}Put them in an array, or validate one at a time

What the error messages mean in different languages

The same mistake produces different messages in different parsers. This tool names the problem in plain words and gives the position.

WhereTypical messageUsual cause
JavaScriptUnexpected token } in JSON at position 42Trailing comma, or a missing value
JavaScriptUnexpected token < in JSON at position 0The server returned an HTML page, not JSON
JavaScriptUnexpected end of JSON inputEmpty response, or a missing closing bracket
PythonExpecting property name enclosed in double quotesSingle quotes, an unquoted key or a trailing comma
PythonExpecting , delimiterA comma is missing between two items
PHPjson_last_error_msg(): Syntax errorAny syntax mistake, with no position

Newer versions of Chrome and Node word these errors differently, but the causes are the same. PHP gives no position at all, so paste the text here to find the exact spot.

Valid JSON vs JSONC, JSON5 and JSON Schema

  • JSONC is JSON with comments and trailing commas, used by VS Code and TypeScript config files. A file such as tsconfig.json is not valid JSON.
  • JSON5 adds single quotes, unquoted keys and more. It needs its own parser.
  • JSON Schema describes what the data must look like, for example that age is a number. This validator checks syntax only. A document can be valid JSON and still be wrong for your API.

Why JSON from an API can be invalid

  • The response is an error page in HTML.
  • A byte order mark comes before the first brace. This tool ignores it, but some parsers reject it.
  • Text was copied from a chat or word processor, which replaced straight quotes with curly quotes.
  • The data was printed with single quotes, as a Python dict or a JavaScript object does.
  • The text was cut off, for example by a log size limit.

Repair suggestion

When the only problems are comments and trailing commas, the tool says so and shows a repaired, formatted version that you can copy. For other errors, fix the marked spot and the check runs again as you type.

Privacy

Validation happens in your browser. The JSON is not sent anywhere.

Next: format or minify the valid JSON, or compare it with another document. If you work with YAML, see the JSON YAML converter. The JSON minification guide covers pitfalls such as big numbers.

Frequently asked questions

How do I validate JSON?

Paste it into the box. The tool says Valid JSON, or shows the first error with its line and column.

Why is JSON with comments invalid?

The JSON standard has no comments. Some tools accept them (JSONC, JSON5), but JSON.parse and most APIs do not.

Are duplicate keys an error?

Not in the standard, but parsers keep only one value and the others are lost, so the validator shows a warning.

What does Unexpected end of input mean?

The JSON stops too early, usually because a closing bracket, brace or quote is missing.

Why do I get Unexpected token < in JSON at position 0?

The text starts with a less-than sign, which usually means the server sent an HTML page, such as an error page, instead of JSON.

Does this validator check a JSON Schema?

No. It checks syntax only. A schema validator checks that the data has the fields and types you expect.