Runs 100% in your browser — nothing is uploaded
JSON & Data Formats

JSON Schema Generator

Infer a draft-07 or 2020-12 JSON Schema directly from a sample JSON payload.

JSON Schema Generator
Client-side

About this tool

The JSON Schema Generator infers a valid JSON Schema document directly from a sample JSON payload — no schema authoring required. Paste a representative API response and the tool walks its structure to produce matching type, properties, items, and required declarations, ready to use for request/response validation, OpenAPI definitions, or form generation.

Object values become type: "object" schemas with a properties map inferred from each key's value; arrays become type: "array" schemas with an items schema inferred from the first element (an empty array produces an empty items schema, since there's nothing to infer from); primitives map directly to string, number, boolean, or null. Nesting of any depth is supported — a deeply nested API response produces a correspondingly nested schema.

Three toggles shape the strictness of the output: "mark all fields required" adds a required array listing every key at each object level, "additionalProperties: false" locks each object schema down to exactly the properties observed (useful for strict validation, but be cautious if your real payloads sometimes include extra fields), and a schema version dropdown switches the $schema declaration between draft-07 (the most widely supported version across validators) and 2020-12 (the current specification version).

Everything runs synchronously in your browser with no external library and no network request — safe to use with real (non-sensitive) sample payloads while building an API contract, an AJV validator, or an OpenAPI spec by hand.

FAQ

How is the schema inferred from just one sample?
The tool recursively walks your parsed JSON and records the type it observes at each key or array position — string, number, boolean, null, object, or array — and for arrays and objects, recurses into their contents. Since it only sees one example, it cannot detect fields that are sometimes present and sometimes absent, or values that could be more than one type across different real payloads.
What does "required" mean in the generated schema?
When "mark all fields required" is enabled, every key present in your sample object is added to that object's required array in the schema, meaning a validator will reject any document missing that key. Since inference is based on a single sample, review the required list before using the schema in production — fields your sample happens not to include won't appear anywhere in the schema at all.
What is additionalProperties: false?
It is a JSON Schema keyword that, when set on an object schema, causes a validator to reject any document containing keys not explicitly listed in properties. Enable it for strict validation where you want to catch typos or unexpected extra fields; leave it off if your real data sometimes legitimately includes extra keys.
Can I validate JSON against the generated schema?
This tool only generates the schema — validating documents against it requires a JSON Schema validator library like Ajv (JavaScript), jsonschema (Python), or an online validator. The output here is standard JSON Schema, so it works with any spec-compliant validator.
Should I choose draft-07 or 2020-12?
Draft-07 has the widest tool and library support and is a safe default for most projects. 2020-12 is the current specification version with additional keywords (like unevaluatedProperties); choose it if your validator and tooling explicitly support it and you need its newer features.