Skip to main content

JSON Validator

Find out exactly what is wrong, and where.

Paste JSON and get an immediate verdict. When something is wrong, Jsonviewpro tells you the line, the column, the character that broke the parse and why it is not allowed — not just “unexpected token at position 582”.

Input JSON

Size: 0 BLines: 0

Paste JSON to validate it

The verdict updates as you type — nothing is uploaded.

Two different questions

People ask “is my JSON valid?” about two unrelated things, and a document can pass one while failing the other badly.

QuestionWhat it checksWhat answers it
Does it parse?Whether the text obeys the JSON grammar: quoting, commas, brackets, number format.Paste it above. The verdict updates as you type.
Is it the right shape?Whether the fields your program needs are present, of the right types, within the right ranges.A JSON Schema, checked further down this page.

A response of {"error":"rate limited"} is perfectly valid JSON and completely useless to code expecting a user record. Syntax validity is the floor, not the goal.

Reading the error

Native parser messages describe where the parser gave up, which is usually one token *after* the mistake, and report a byte offset rather than a place a person can navigate to. A missing comma on line 12 is commonly reported at the start of line 13.

Jsonviewpro re-scans failing input to report the location and the cause separately:

What you get instead of “Unexpected token at position 582”
Invalid JSON        Line 3, Column 28

Trailing comma before the closing bracket.
Remove the comma after the last array item.

   3 │   "roles": ["admin", "user",]
     │                           ^

Go to line jumps the cursor there. Try repair appears only when the fix is unambiguous, and tells you exactly what it changed — your input is never altered without you asking.

Every reason a document fails to parse

This is the complete set, with the message Jsonviewpro gives for each. In practice the first five account for almost everything.

ExampleWhat you will seeFix
["admin", "user",]Trailing comma before the closing bracket.Delete the comma after the last item. Legal in JavaScript, never in JSON.
{'name': 'John'}Single quotes are not valid in JSON.Use double quotes. Usually the result of pasting a Python dict or a JS object literal.
{name: "John"}"name" is not quoted.Quote every property name.
{"a": 1} // noteComments are not allowed in JSON.Strip them. VS Code settings files are JSONC, not JSON.
{"ok": True}"True" is Python syntax, not JSON.Use lowercase true, false, null.
{"n": NaN}"NaN" is not a valid JSON value.JSON has no NaN or Infinity. Use null, or a string.
{"a": 1 "b": 2}Expected "," or "}" after the property value.A comma is missing — usually a dropped line after a paste.
{"a": "unterminated}The string is never closed.Often a Windows path ending in a backslash, which escaped the closing quote.
{"n": 007}Numbers cannot have a leading zero.Write 7, or quote it if it is really a code.
{"a":1} {"b":2}Unexpected content after the end of the JSON value.A document holds exactly one top-level value. This is probably NDJSON.
{"a": "line\nbreak"}A string cannot span multiple lines.Escape the newline as \n rather than pressing Enter inside the quotes.
{"a": [1, 2Unexpected end of input: an array is never closed.The response was probably truncated — check for a timeout upstream.

Valid, and still wrong

These parse cleanly, so no validator will complain, and each has caused real production incidents:

  • Duplicate keys. {"a":1,"a":2} is permitted by the specification, which declines to say what a parser should do about it. JavaScript and Python keep the last occurrence; some parsers keep the first; a few throw. Never emit them.
  • Integers beyond 2^53 − 1. 9007199254740993 parses to 9007199254740992 in any JavaScript engine. Nothing warns you. Send large identifiers as strings.
  • An empty body. Zero bytes is not valid JSON, but a literal null, {} or [] is — and each means something different from the others.
  • HTML pretending to be JSON. A login redirect or a proxy error page will fail to parse with a confusing message. Check the status code and Content-Type before you blame the JSON.

Checking the shape with a JSON Schema

Open Validate against a JSON Schema above and paste a schema next to your document. Each violation is reported with the path that failed.

Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["id", "email"],
  "properties": {
    "id":     { "type": "integer", "minimum": 1 },
    "email":  { "type": "string", "format": "email" },
    "status": { "enum": ["active", "invited", "disabled"] }
  }
}
Result for {"id": "one"}
$          Instance does not have required property "email".
$.id       Instance type "string" is invalid. Expected "integer".

Drafts 04, 07, 2019-09 and 2020-12 are all supported, chosen automatically from the schema’s own $schema. Validation runs in your browser, and $refs to remote schemas are never fetched.

Validate at the boundary, not in the middle

The lesson from most JSON-related incidents is not “validate more”, it is “validate early”. Check the payload the moment it arrives — at the API handler, the queue consumer, the file loader — and reject it there with a message naming the field.

A malformed document that travels three services deep produces a stack trace in the wrong place, and the engineer reading it has no idea which upstream sent it.

Validating in a script or CI

# Is it valid? Exit status only.
jq empty input.json && echo valid

# Python, with the position of the failure
python3 -c "import json,sys; json.load(open(sys.argv[1]))" input.json

# Every JSON file in a repository, as a pre-commit check
find . -name '*.json' -not -path './node_modules/*' -exec jq empty {} ;

# Against a schema, in CI
npx ajv-cli validate -s schema.json -d data.json

Frequently asked questions

Why does my JSON fail here when it works in JavaScript?
JavaScript object literals are a superset of JSON. Unquoted keys, single quotes, trailing commas, comments and values such as undefined are all legal JavaScript and invalid JSON.
Can Jsonviewpro fix my JSON automatically?
It suggests a repair for unambiguous problems — trailing commas, single quotes, comments, unquoted keys and Python literals — and shows exactly what it changed. Nothing is applied unless you click it.
Which JSON Schema drafts are supported?
Drafts 04, 07, 2019-09 and 2020-12, selected automatically from the schema’s $schema property.
Are duplicate keys invalid?
No — the specification permits them but does not define the behaviour, which is worse. Most parsers keep the last occurrence. Treat them as a bug in whatever produced the document.
My file looks fine but will not parse. What else could it be?
A byte order mark at the start of the file, a non-breaking space pasted from a document, an unescaped control character inside a string, or an HTML error page being returned instead of JSON. Jsonviewpro names the exact character and position for each.
Is my data sent anywhere to validate it?
No. Both syntax checking and schema validation run in your browser. Schema validation uses an interpreter rather than a code generator, so it needs no eval and nothing is compiled or uploaded.