JSON Schema Generator

Paste a JSON sample, get back a JSON Schema (draft 2020-12) that validates it. Useful for adding schema validation to an API where you have example responses but no schema, or for sanity-checking that a payload matches an expected shape.

How to use the JSON Schema Generator

Paste a JSON sample (or array of samples — the tool merges shapes). Pick the draft (2020-12 is current; draft-07 for older tooling like AJV without v8 plugins). "All required" assumes every field in the sample must be present in valid documents — uncheck if your sample might have optional fields you haven't included.

About JSON Schema

JSON Schema is the standard way to describe and validate JSON structure. A schema lets your API reject malformed requests with specific error messages, and lets downstream tools (TypeScript generators, OpenAPI docs, code generators) understand the shape of your data.

Draft 2020-12 is the current spec; draft-07 is older but widely supported. The big practical difference is how arrays of mixed types are described and how $dynamicRef works. For most uses, the generated schemas are interchangeable.

Frequently asked questions

Which JSON Schema draft does it output?

Draft 2020-12, the current standard. The output validates the sample you provide and is a starting point you can tighten by hand.

Does it infer required fields?

Optionally. It can mark the keys present in your sample as required, which you can then prune for fields that are genuinely optional.

Will one sample produce a complete schema?

It captures the shape of that sample, but it cannot know about optional fields, enums or formats it never saw. Provide a representative sample and refine the result.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: