Skip to content

Is My JSON Valid? How to Tell Syntax Errors from Schema Mismatches

Check if JSON is valid free online — tells syntax errors from schema mismatches, with fixes for common JSON errors. No sign-up.

Try it now: JSON Formatter & Validator Format, validate and minify JSON in your browser. Pinpoints syntax errors by line and column, sorts keys for clean diffs, and never uploads your data.

Invalid Can Mean Two Different Things

Trying to check if JSON is valid sounds like one question, but it is actually two, and almost every JSON tool on the first page of search results blurs them together under a single "validator" label. Sorting out which one you are actually asking — and why your JSON is invalid in the first place — is the fastest way to fix the problem in front of you.

  • Syntactically broken — the text does not parse as JSON at all. A trailing comma, a single-quoted string, an unquoted key: the document never becomes data in the first place, and every parser in every language rejects it the same way.
  • The wrong shape— the text parses just fine, but it does not match the structure you (or an API contract) expected: a required field is missing, a price came back as a string instead of a number, an enum value isn't one of the allowed options. This is a schema mismatch, not a syntax error — the document is valid JSON, just not the JSON you needed.

Those two failures need different tools and different fixes, which is the whole reason this page exists instead of just pointing everyone at one generic checker.

Path 1: Is It Broken? (Syntax)

If the error happens the instant something tries to parse the text — a JSON.parsethrow, a 400 from an API that rejected the request body, a build tool refusing to read a config file — you're on the syntax path. The common JSON syntax errors below cause almost all of it:

common syntax breaks
{
  "name": 'Ava',        // single quotes — always invalid in JSON
  status: "active",     // unquoted key — always invalid in JSON
  "roles": ["admin",],  // trailing comma before ] — invalid
  // a comment          // comments don't exist in JSON, in any position
}
  • Trailing comma before } or ] — legal in a JavaScript object literal, never legal in JSON. Delete the comma after the last property or element.
  • Single-quoted strings, or unquoted keys — JSON requires double quotes around every string and every key, no exceptions. Replace ' with " and quote bare keys.
  • Comments (// or /* */) — valid in JSONC files like tsconfig.json, never valid in strict JSON. Strip them before feeding the file to a strict parser.
  • Truncated input— "unexpected end of input" almost always means the payload got cut off mid-copy, or a streamed response never finished.

This is exactly what GenKitLab's JSON Formatter checks: it runs your input through a real parser and, if it fails, locates the exact line and column where it stopped being valid JSON — including the one case (a trailing comma right before a closing brace) that Chrome's own JSON.parse reports with no position at all. The full JSON formatter guide goes deeper into every syntax rule and the exact wording each JavaScript engine uses for the same mistake.

Path 2: Is It the Wrong Shape? (Schema)

If the text parses without complaint but something downstream still breaks — a required field is missing, a type is wrong, a value falls outside an allowed range — you're past syntax entirely. This is a structural question: does this JSON document match the shape a contract describes? That contract is usually written as a JSON Schema, and checking a document against one is a distinct, heavier operation than confirming it parses.

A schema can require specific fields, constrain a value's type, cap a number's range, or restrict a string to a fixed set of options — none of which a syntax parser has any way to know about, because none of it is expressed in JSON's own grammar.

GenKitLab's JSON Schema Validator checks a document against a JSON Schema (draft 2020-12) and locates every failure by JSON Pointer, so you know exactly which field violated which rule rather than a single pass/fail verdict. If you're new to what that actually involves — required fields, types, the current draft, and worked examples with real validation-library code — the JSON Schema Validator guide is the deeper companion to this page.

Quick Diagnosis

Not sure which path you're on? Start with syntax — it's the cheaper check, and it's a precondition for the other one anyway: a schema validator can't evaluate a document that never parsed.

  1. Paste the text into the JSON Formatter. If it fails, you have your answer — fix the line and column it points to.
  2. If it formats cleanly but the data still isn't what you expected — a missing field, a wrong type, an out-of-range value — move to the JSON Schema Validator and check it against the shape you actually need.

Frequently asked questions

Is my JSON valid — how do I check?

Paste it into a real parser and see whether it throws. GenKitLab's JSON Formatter is a json validator online that does this in your browser and, if the document fails, points at the exact line and column where parsing stopped — rather than leaving you to guess from a generic "unexpected token" message.

Why does my JSON fail to parse?

Almost always one of a few causes: a trailing comma before } or ], single-quoted strings or unquoted keys, a // or /* */ comment (valid in JSONC, never in strict JSON), or a JavaScript-only value like undefined or NaN. Truncated input — a payload that got cut off mid-copy — is the other common cause.

What's the difference between invalid JSON and JSON that doesn't match my schema?

Invalid JSON fails to parse at all — it never becomes data, and every parser rejects it identically. JSON that doesn't match your schema parses just fine; the data exists, but it's missing a required field, uses the wrong type, or falls outside an allowed range. The first is a syntax problem; the second is a structural one, and it needs a JSON Schema to check against.

What's the most common reason JSON fails to validate?

For syntax: a trailing comma before a closing brace or bracket, which is legal in a JavaScript object literal but never legal in JSON. For schema validation: a missing required property, since that's the single easiest thing for a hand-edited or partially-populated payload to omit.

Can a validator tell me exactly where the problem is?

A good syntax check reports a precise line and column, plus the offending character — GenKitLab's JSON Formatter does this even for the one case (a trailing comma right before a closing brace) that Chrome's native JSON.parse reports with no position at all. A schema validator reports the same precision differently: by JSON Pointer, e.g. /items/2/price, naming the exact value and the rule it broke.

Do I need JSON Schema just to check basic validity?

No. Confirming a document parses as JSON needs nothing more than a parser — that's the syntax check. JSON Schema is a separate, heavier tool you only need when you want to verify that already-valid JSON also matches a specific expected shape: required fields, types, ranges, and similar structural rules.

Last updated