JSON Schema Generator
Paste JSON data to automatically infer a JSON Schema. Supports Draft-07 and Draft-04. 100% client-side.
How to Use the JSON Schema Generator
- Paste your JSON data — any valid JSON object or array of objects.
- Choose a draft version — Draft-07 (recommended for new projects) or Draft-04 (for older tooling compatibility).
- Use "Required All" to mark every property as required, or leave it off for a more permissive schema.
- Copy or download the generated schema for use in API validators, documentation, or code generation tools.
What is JSON Schema?
JSON Schema is a specification for describing the structure and constraints of JSON data. It defines what properties an object must have, what types are allowed for each property, and additional constraints like minimum/maximum values, string patterns, and array lengths. JSON Schema is widely used for API request/response validation, auto-generating forms from data models, API documentation (OpenAPI uses JSON Schema internally), and enforcing data contracts between services.
Draft-07 vs. Draft-04
The most common versions of JSON Schema in production are Draft-07 and Draft-04. Draft-04 is the older baseline, supported by virtually every validator. Draft-07 adds useful features including if/then/else for conditional validation, readOnly and writeOnly keywords for documenting API behavior, $comment for schema documentation, and contains for arrays. The generated $schema URI changes between versions, which tells validators which rules to apply.
How Schema Inference Works
This generator performs a recursive traversal of your JSON data. For each value it encounters, it detects the JSON Schema type — string, number, integer, boolean, null, array, or object. For numbers, it checks whether the value is an integer or a floating-point number and uses the more specific integer type when appropriate. For arrays, it examines the first element to determine the items schema. For objects, it recursively generates a properties block.
Refining the Generated Schema
The generated schema is based on a single sample, which means it may not capture all real-world variation. After generating, review and refine it by adding enum constraints for fields with a fixed set of values, format annotations for strings that represent dates, emails, or URIs, minimum and maximum for numeric ranges, minLength and maxLength for strings, and pattern for string format validation using regular expressions. These additions make the schema more precise and useful as a validation contract.
Using the Schema with Validators
Once you have a schema, you can validate JSON documents against it using Ajv (JavaScript/Node.js — the most popular validator), jsonschema (Python), json-schema-validator (Java), or JsonSchema.Net (.NET). For API development, OpenAPI 3.x schemas use a superset of JSON Schema Draft-07, so generated schemas can often be used directly in Swagger/OpenAPI specifications. Validate your schema itself using the JSON Schema meta-schema to catch errors before deployment.