JSON Schema Generator — Free Online Tool 2026
JSON Schema Generator creates a valid JSON Schema from any JSON sample in one click. Choose between draft-07 (maximum compatibility) and 2020-12 (latest standard), toggle all-fields-required on or off, and optionally detect format hints for dates and emails. Use the output with AJV, jsonschema (Python), or any standards-compliant JSON Schema validator.
How It Works
- Choose the JSON Schema draft version
- Paste any JSON object or array
- The schema is generated with type, properties, and required array
- Copy and use with your validation library
JSON Schema — Validation, Documentation, and Code Generation
JSON Schema (IETF draft, now heading toward RFC) is the standard vocabulary for describing the structure and constraints of JSON data. A schema specifies what a valid JSON document looks like: which fields are required, what type each field must be, and additional constraints like string formats, numeric ranges, and array lengths. This generator creates a starting schema from a JSON sample, which you can then refine to add the constraints specific to your API contract. After generating, use the schema with AJV (JavaScript), jsonschema (Python), NJsonSchema (.NET), or Vert.x (Java). To explore the structure of the input JSON, use the JSONPath Finder before generating the schema. For TypeScript projects, also generate TypeScript interfaces alongside the schema.
Draft-07 vs 2020-12 — Which to Choose
JSON Schema draft-07 is the most widely supported version and works with virtually all validation libraries including AJV 6+, jsonschema 4 (Python), tv4, and most IDE JSON Schema support. It uses definitions for reusable sub-schemas and items for array validation. Draft 2020-12 is the current official standard. It uses $defs (renamed from definitions), adds prefixItems for tuple schemas, improves $ref behavior, and supports the unevaluatedProperties keyword for stricter object validation. This generator supports both. Choose draft-07 for existing projects and 2020-12 for new ones.
Required vs Optional Fields
When the "All sampled keys required" option is on, every key in the input JSON is added to the schema's required array. This is appropriate if you are generating a schema for data you control. If you are generating a schema for a third-party API that may omit fields, turn this option off — no required array will be generated, and all fields will be treated as optional. The best approach is to start with all required and then remove keys from the required array for fields that are genuinely optional. If you have multiple JSON samples from the same API, use the JSON Diff tool to identify which fields vary between responses before deciding which to mark as optional.
Format Detection and Additional Constraints
The JSON Schema format keyword is an annotation (not enforced by default in most validators) that hints at the intended format of a string value. This generator automatically adds "format": "date-time" for strings that look like ISO 8601 datetime values, and "format": "email" for strings that resemble email addresses. These are informational — to enforce format validation, configure your validator to enable format assertions. Other constraints you may want to add manually: minimum/maximum for numbers, minLength/maxLength for strings, pattern for regex-constrained strings, enum for fixed-value fields, and additionalProperties: false to reject unknown keys.
Frequently Asked Questions
JSON Schema is a vocabulary for annotating and validating JSON documents. A schema describes the shape of a JSON document: which keys are required, what types each field must have, and constraints like minimum/maximum values. It is used to validate API payloads, generate documentation, and drive form validation.
Draft-07 is the most widely supported version, compatible with AJV, jsonschema (Python), and most libraries. Draft 2020-12 is the latest standard with better keywords and reference support. Choose draft-07 for maximum compatibility and 2020-12 for new projects.
The schema is inferred from a single JSON sample and captures types and required fields. Review and add additional constraints like minimum/maximum, string patterns, enum values, and additionalProperties based on your actual API contract.
For arrays with elements, the generator infers the item schema from the first element (or merges types if elements differ). The items keyword describes the schema each element must match. For empty arrays, the item schema is set to {}.
Comments