How to use the JSON Schema Generator
Generate a complete JSON Schema in seconds:
1
Paste your JSON
Paste any JSON object or array. The generator reads the structure and infers types from all values.
2
Set a title
Enter a schema title — it appears in the $schema output and helps identify the schema in your tooling.
3
Choose schema draft
Select draft-07 (recommended for maximum compatibility with Ajv, OpenAPI, and most validators) or 2020-12 (latest spec).
4
Click Generate
Get a complete JSON Schema with $schema, title, type, properties, required, additionalProperties, and inferred format keywords.
5
Refine and use
Copy the schema and add constraints like minLength, minimum, maximum, enum, or pattern as needed before wiring it into your validator.
When to use this tool
Use this whenever you need to document, validate, or enforce the structure of JSON data:
- →Documenting API request and response shapes with JSON Schema for OpenAPI 3.0 or Swagger specs
- →Creating a validation schema for a JSON config file to catch invalid values at startup
- →Generating a base schema from real API sample data to validate future responses with Ajv
- →Building form validation using JSON Schema-compatible libraries like react-jsonschema-form or Ajv
- →Generating schemas for MongoDB JSON Schema validation rules or PostgreSQL JSON columns
- →Creating a JSON Schema to power autocomplete and validation inside VS Code for config files
Frequently asked questions
Q:Which JSON Schema drafts are supported?
The tool generates draft-07 (most widely supported) and 2020-12 (latest spec) schemas. Draft-07 is recommended for maximum compatibility with Ajv, jsonschema (Python), OpenAPI 3.0, and most validation tools. Choose 2020-12 if your tooling explicitly supports it — it has a cleaner spec and better support for recursive schemas.
Q:Are all fields marked as required by default?
Yes — all non-null fields found in the sample JSON are added to the required array. This is the safest default for validation. Remove fields from required that are genuinely optional in your data model, and update null fields to use the correct type (e.g. string | null) before using in production.
Q:Can I use the generated schema with Ajv?
Yes. The output is fully compatible with Ajv, the most popular JavaScript JSON Schema validator. For draft-07 schemas, use new Ajv().compile(schema). For 2020-12, use new Ajv2020().compile(schema) from the ajv/dist/2020 import. additionalProperties: false is set by default, which Ajv enforces strictly.
Q:What format keywords are inferred automatically?
The generator infers five format keywords from key names and values: format: "email" when the key contains 'email', format: "uri" for keys containing 'url', 'uri', or 'link', format: "uuid" for keys containing 'uuid' or 'guid', format: "date-time" for ISO 8601 string values, and format: "date" for YYYY-MM-DD strings. The auto-detected formats panel below the output shows all five rules.
Q:How are nested objects and arrays handled?
Nested JSON objects generate nested properties blocks with their own type, properties, required, and additionalProperties fields. JSON arrays generate an items keyword with a typed schema for the array element. Arrays of objects generate a full object schema inside items.
Q:Can I use the schema with OpenAPI / Swagger?
Yes, with one caveat: OpenAPI 3.0 uses a subset of JSON Schema draft-07, so generate with draft-07 selected and paste the properties block into your OpenAPI component schemas. OpenAPI 3.1 is fully compatible with JSON Schema 2020-12 — generate with 2020-12 and the schema can be used directly.