You paste a JSON document into a tool, it says the JSON is valid, and you move on — then your app crashes because the age field holds a string instead of a number, or a required email field is missing entirely. Nothing was wrong with the verdict. The tool answered the only question it was built to answer: is this well-formed JSON? Whether the JSON means what your code expects is a different question, and it needs a different tool.
This guide explains the two kinds of JSON validation — syntax validation and schema validation — what each one checks, when each one applies, and the simple workflow that uses both in the right order.
Syntax validation: is it JSON at all?
Syntax validation checks a document against the JSON grammar defined in RFC 8259, the standard that specifies exactly what counts as JSON. It asks one question: can a parser read this? A syntax validator catches missing or extra commas, trailing commas, unquoted keys, single quotes where double quotes are required, mismatched brackets and braces, invalid escape sequences, and numbers like 01 or .5 that strict JSON forbids. Its output is a verdict — valid or invalid — plus the exact line and column of the first error, so you can fix it instead of guessing. A JSON Validator does exactly this, in your browser, without sending your data anywhere.
What syntax validation cannot do is say anything about meaning. The document {"name": "Taha", "age": "twenty"} is perfectly valid JSON — it parses without complaint — yet it will break any code that expects age to be a number. A document can be syntactically flawless and still be wrong for your purpose: a missing field, a mistyped key, a value of the wrong type, a number outside the allowed range. Syntax validation is the gate at the door; it checks the envelope, not the letter inside.
Schema validation: does it match the shape you expect?
A JSON Schema is itself a JSON document that describes the shape another document must have: which properties are required, what type each value must be, the allowed range of a number, the pattern a string must match, and whether extra properties are permitted. A schema validator takes two inputs — your data and your schema — and reports every place the data breaks the rules. Where a syntax validator asks 'can this be parsed?', a schema validator asks 'is this the data I asked for?'
Take a schema for a user record: name must be a string, age must be an integer of 0 or more, and email is required. The document {"name": "Taha", "age": "twenty"} passes syntax validation but fails schema validation — age is a string, not an integer. A document with no email field fails too, because email is required. And {"name": "Taha", "age": 30, "email": "taha@example.com"} passes both checks: it parses, and it matches the shape. That second verdict is the one your code actually depends on.
Schemas act as contracts between systems. An API provider publishes a schema so consumers can check a payload before sending it, instead of discovering the problem from a 400 error. A team validates configuration files against a schema in CI, so a mistyped setting fails the build instead of taking down production. A data pipeline validates incoming records against a schema and quarantines the ones that do not match, rather than letting bad rows corrupt a database. In each case the schema is written once and enforced everywhere the data flows.
One detail worth knowing: JSON Schema's format keyword — used to declare that a string should look like an email address, a date, or a URI — is treated as an annotation by many validators, which means they record the declaration but do not enforce it unless format assertion is turned on. If an email-shaped string is a hard requirement, enforce it with a pattern rule as well, or check that your validator asserts formats. The current version of the specification is draft 2020-12, and most modern validators support it.
Syntax validation vs schema validation
The two checks answer different questions, take different inputs, and fail for different reasons. Neither one replaces the other.
| Syntax validation | Schema validation | |
|---|---|---|
| Question answered | Can this be parsed as JSON? | Does this match the shape I defined? |
| Inputs | The JSON document | The JSON document + a schema |
| Output | Valid/invalid + error position | Pass/fail + list of rule violations |
| Catches | Missing commas, unquoted keys, bad escapes | Wrong types, missing fields, out-of-range values |
| Misses | Everything about meaning | Syntax errors — it cannot even read invalid JSON |
| Use it when | Debugging a parse error, quick checks | Enforcing contracts, config, API payloads |
Worked example: the same data, three verdicts
Imagine a small user record moving through both checks. The three outcomes below show why you need both, and in which order:
- Broken syntax: {"name": "Taha", "age": 30,} — the trailing comma after 30 is not allowed in JSON. Syntax validation fails, and schema validation never gets a chance to run: a schema validator cannot read a document that does not parse.
- Valid syntax, wrong shape: {"name": "Taha", "age": "thirty"} — this parses cleanly, so syntax validation passes. Schema validation fails it: age must be an integer, and "thirty" is a string.
- Valid on both: {"name": "Taha", "age": 30, "email": "taha@example.com"} — it parses, every field has the right type, and the required email is present. This is the only document of the three that is safe to hand to your code.
The workflow: syntax first, then shape
For almost any JSON task, this order covers it:
- Validate syntax — paste the raw JSON into the JSON Validator. If it fails, fix the reported error and validate again until it passes.
- Format for reading — once it is valid, run it through the JSON Formatter so you can see the structure and spot problems your eyes missed.
- Validate shape — check the formatted document against your schema with the JSON Schema Validator. Fix every reported mismatch: wrong types, missing fields, values out of range.
- Ship it — only a document that passes both checks goes to your API, your config, your tests, or your database.
When you only need one
Syntax validation alone is enough when you are the only consumer and you already know the shape: debugging a parse error in a pasted API response, checking a config file you wrote by hand, or confirming that a file you just edited still parses. In those cases the shape is in your head, and a quick syntax check is all that stands between you and done.
Schema validation earns its place the moment data crosses a boundary: an API you do not control, a form submission from a user, a config file edited by a teammate, a payload generated by another system, or any input that reaches your code in production. Wherever you cannot vouch for the data yourself, a schema does the vouching for you — and it does it the same way every time, without getting tired or distracted.
In practice the choice is never 'syntax or schema'. Schema validation always implies syntax validation, because a schema validator must parse the document before it can check it against the schema — invalid JSON fails at the parse step. The real question is whether syntax alone is enough, or whether the data deserves the second check as well.
Common mistakes
The first mistake is treating a green syntax verdict as proof the data is correct — it only proves the data parses. The second is writing a schema but never running it: a schema sitting in a repository, unenforced, is documentation, not validation. The third is validating only a happy-path sample and shipping, then discovering that real data has missing fields, null values, and types nobody expected. The fourth is an over-strict schema: rejecting extra properties outright, for example, breaks forward compatibility the first time an API adds a field. Validate what matters, tolerate what does not, and run the checks on real data before you trust them.
Try it yourself
Frequently asked questions
Is JSON Schema validation the same as JSON validation?
No. JSON validation usually means syntax validation — checking a document parses according to RFC 8259. JSON Schema validation is a second, stricter check: it compares the document against a schema that defines the required shape, types, and values. A document can pass the first and fail the second.
Can a schema validator check invalid JSON?
No. A schema validator has to parse the document before it can compare it with the schema, so invalid JSON fails at the parse step. Validate the syntax first, fix any errors, and only then run the schema check.
Do I need a schema for every JSON document?
No. A schema is worth writing when data crosses a boundary — an API contract, a config file others edit, user input, or data flowing into a database. For a quick one-off check of JSON you wrote yourself, syntax validation alone is usually enough.
What does a JSON Schema look like?
It is a JSON document made of keywords: type says what kind of value is allowed, properties describes the fields of an object, required lists the fields that must be present, and keywords like minimum, maximum, and pattern constrain values further. A minimal schema can be as short as {"type": "object", "required": ["email"]}.
Can I validate JSON against a schema in the browser?
Yes. The JSON Schema Validator on this site runs entirely in your browser: paste your data and your schema, and it lists every place the data breaks the schema's rules. Nothing is uploaded, so API keys and production payloads stay on your machine.