JSON Schema Generator — JSON to Schema & Schema to JSON
Generate a JSON Schema from any JSON object, or switch modes to generate sample JSON from an existing schema. Detects string formats, types, and nested structures.
About this tool
Generate a JSON Schema from an example JSON document to document and validate your API payloads, or go the other way and generate sample JSON from an existing schema. Supports Draft-07, 2019-09 and 2020-12.
Example use case: Create a schema from a sample request body for OpenAPI or AJV validation, or turn a schema into a realistic test payload.
Mode:
Draft:
Title:
Frequently Asked Questions
What is a JSON Schema?▾
JSON Schema is a vocabulary for annotating and validating JSON documents. It describes the structure of JSON data including types, required fields, and format constraints.
Which JSON Schema draft should I use?▾
Draft-07 is the most widely supported. Draft 2019-09 and 2020-12 are newer and add features. If you're using AJV, Zod, or similar libraries, check their supported draft.
What formats are automatically detected?▾
The generator detects date (YYYY-MM-DD), date-time (ISO 8601), UUID (8-4-4-4-12 hex), email, and URI formats from string values.
Can I generate sample JSON from a JSON Schema?▾
Yes. Switch the mode to "Schema → Sample JSON" and paste your schema. The generator uses examples, default, const and enum values when present, fills in realistic values for formats like email, UUID and date-time, respects minimum and minItems, and resolves local $ref, allOf, oneOf and anyOf.
What is the difference between Draft-07, 2019-09 and 2020-12?▾
Draft-07 uses "definitions" for reusable schemas and is supported almost everywhere. Draft 2019-09 renamed it to "$defs" and added keywords like unevaluatedProperties. Draft 2020-12 replaced tuple-style "items" arrays with "prefixItems". The generator sets the matching $schema URL for the draft you pick.
How do I validate JSON against the generated schema?▾
In JavaScript, use AJV: new Ajv().compile(schema) returns a validate function. In Python, use the jsonschema package: jsonschema.validate(instance, schema). Most OpenAPI tools also accept the generated schema directly.
Why are all fields marked as required?▾
A single JSON sample can't show which fields are optional, so every non-null field is marked required by default. Turn off "required fields" or edit the required array after generating.
Is my JSON or schema sent to a server?▾
No. Schema generation and sample generation both run entirely in your browser. Nothing you paste is uploaded.