JSON Schema Generator

Paste JSON data to automatically infer a JSON Schema. Supports Draft-07 and Draft-04. 100% client-side.

JSON Input
JSON Schema Output
Paste JSON above to generate a schema.

How to Use the JSON Schema Generator

  1. Paste your JSON data — any valid JSON object or array of objects.
  2. Choose a draft version — Draft-07 (recommended for new projects) or Draft-04 (for older tooling compatibility).
  3. Use "Required All" to mark every property as required, or leave it off for a more permissive schema.
  4. 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.

Frequently Asked Questions

JSON Schema is a vocabulary for annotating and validating JSON documents. It describes the structure of JSON data — what properties are required, what types are allowed, and what constraints apply. JSON Schema is used for API validation, form generation, documentation, and data contracts.
Draft-07 is the most widely supported modern version and adds features like if/then/else conditionals, readOnly/writeOnly, and $comment. Draft-04 is the older baseline used by many legacy validators. Both are supported by popular libraries like Ajv. Use Draft-07 for new projects and Draft-04 for compatibility with older tooling.
No. This JSON Schema generator runs 100% in your browser using JavaScript. Your data never leaves your machine. There is no server-side processing, no logging, and no data collection.
The generator marks all non-null fields present in the sample JSON as required. In "Required All" mode, every property that appears in the sample is added to the required array. Fields with null values are still included in properties but are given an anyOf type to allow null. You can manually edit the generated schema to adjust which fields are truly required.
Yes. The generated schema is a starting point for API validation. Use it with validators like Ajv (JavaScript), jsonschema (Python), or json-schema-validator (Java). Review and refine the schema — the generator infers types from a single sample, so it may not capture all edge cases like optional fields, enum values, or string format constraints.