A JSON Schema is a document that describes the shape of your JSON: which fields exist, what type each one is, and which are required. If you have a sample payload and want to validate future data against it, the fastest path is to generate a starting schema from the example, then tighten it by hand. Here is how that works.
What JSON Schema is for
JSON Schema is a standard vocabulary for describing JSON data. Instead of checking fields one by one in code, you write a schema once and use a validator to confirm any payload matches it. The same schema works across languages, so a Python service and a JavaScript client can agree on exactly what valid data looks like.
Common uses:
- API validation: reject malformed request bodies and verify response shapes.
- Config validation: catch typos and missing keys before an app boots.
- Form and UI generation: drive form fields and editors from the schema.
The core keywords you will see:
- type: the data type, like
string,number,object,array, orboolean. - properties: the named fields inside an object and the schema for each.
- required: an array of property names that must be present.
- items: the schema each element of an array must match.
- enum: a fixed list of allowed values for a field.
Not the same as schema.org
One common mix-up: JSON Schema is not JSON-LD or schema.org structured data. Schema.org markup describes the meaning of page content for search engines, embedded as JSON-LD. JSON Schema describes the structure of arbitrary JSON for validation. Different problems, different tools. This post is about the validation kind.
Generate a JSON Schema in four steps
A generator reads your sample and infers a reasonable draft. It cannot read your mind, so treat the output as a first pass you will refine.
- Open the JSON Schema Generator and paste a representative JSON example.
- Read the generated schema. It infers a
typefor every value and buildspropertiesfor each object key, withitemsfor arrays. - Tighten the draft. Mark fields as
requiredwhere they must always appear, swap loose types for anenumwhere only certain values are valid, and add constraints likeminLength,minimum, or stringformat(email,date-time,uri). - Copy the finished schema and drop it into your validator (Ajv, jsonschema, and friends all read the same format).
The JSON Schema Generator runs entirely in your browser, so your sample data never leaves your device. A generator infers structure, but it cannot know your business rules, so the refining step is where a useful schema is actually made.
Related tools
- Messy sample JSON? Clean it first with the JSON Formatter.
- Need to pull specific values out of JSON? Use the JSONPath Tester.
- Flattening records for a spreadsheet? Try JSON to CSV.
Start from a real example, let the generator draft the structure, then tighten the rules until invalid data has nowhere to hide.