JSON Schema Generator and Validator

Generate a JSON Schema from a sample document, then validate other JSON against it and see every problem by path. It runs in your browser and nothing is uploaded.

Loading the tool. It runs entirely in your browser...

Generate, edit, validate

A JSON Schema describes what valid data looks like: which properties exist, which are required, and what type each value must have. Writing one by hand for a large payload is tedious, so start from a sample. Paste a representative document, press Generate schema, and you get a draft 2020-12 schema describing it.

The generator infers types (string, integer, number, boolean, null, array, object), marks keys as required, and recognises common string formats such as email, date-time, uuid and uri. You can forbid extra properties with additionalProperties: false. The schema is just text in an editable box, so tighten it by hand with minimum, maxLength, pattern, enum and similar keywords.

Then paste any document into the validation box. Each problem is listed with the path to the offending value, for example $.tags[0] Expected string but found integer. The validator supports the keywords used in everyday schemas, including $ref to local #/$defs/... definitions, anyOf, oneOf, allOf and not.

Worked example

Sample:

{"id": 7, "email": "ann@example.com", "tags": ["a"], "profile": {"active": true}}

Generated schema (shortened):

{
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "email": { "type": "string", "format": "email" },
    "tags": { "type": "array", "items": { "type": "string" } },
    "profile": { "type": "object", "properties": { "active": { "type": "boolean" } }, "required": ["active"] }
  },
  "required": ["id", "email", "tags", "profile"]
}

Validating {"id":"seven","tags":[1]} reports that $.id must be integer, $.tags[0] must be string, and that email and profile are missing.

Limits of a generated schema

One sample cannot reveal which fields are optional, which numbers have ranges, or which strings are really enums. Treat the output as a starting point. Review the required list, add constraints that reflect your real rules, and consider generating from several samples. For remote $ref URLs and the full draft vocabulary use a dedicated validator in your build pipeline; this page checks local references only so nothing is ever fetched.

Frequently asked questions

Which JSON Schema version is generated?

Draft 2020-12, declared in the $schema keyword. The keywords produced, such as type, properties, required, items and format, are also valid in earlier drafts.

Does validation fetch remote schemas?

No. Only local references that start with #/ are resolved. The tool never makes network requests, so your data and schema stay in the page.

Why are all the keys marked required?

A single sample cannot tell optional keys from required ones, so the generator assumes every key in the sample is required. Untick Mark keys as required, or edit the schema, if that is too strict.

Are format keywords enforced?

Yes, for email, date-time, date, uuid, uri and ipv4. Formats are checked with practical patterns rather than full RFC grammars, so very unusual but technically valid values might be flagged.