JSON Schema Generator
Paste any JSON data and automatically generate a valid JSON Schema. All processing happens locally in your browser.
About JSON Schema Generator
JSON Schema is a powerful vocabulary for annotating and validating JSON documents. It provides a contract for what data a JSON document should contain, what types each field should be, which fields are required, and what constraints apply. JSON Schema is widely used in API development for request and response validation, form generation, documentation, and automated testing. By defining a schema, teams can ensure data consistency across services, catch invalid data before it causes runtime errors, and generate human-readable documentation automatically.
This JSON Schema Generator lets you paste any valid JSON and instantly produces a corresponding JSON Schema that describes the structure of your data. The tool runs entirely in your browser with no server-side processing, so your data remains completely private. It analyzes nested objects recursively, detects array item types, handles mixed-type arrays with anyOf, and properly represents null values. You can choose from multiple JSON Schema draft versions to match the version required by your validation library or toolchain.
Supported Draft Versions
The tool supports five JSON Schema specifications: Draft-04, Draft-06, Draft-07, 2019-09, and 2020-12. Draft-07 is the default and is the most widely supported version across validation libraries and tools. Draft-04 is the oldest supported version and remains common in legacy systems. The 2019-09 and 2020-12 specifications are the latest versions, introducing features like prefixItems for tuple validation and vocabulary-based extensibility. Each version uses its own $schema URI to indicate which specification the schema conforms to.
How It Works
The generator traverses your JSON data recursively, building a schema tree that mirrors the structure of the input. For each value, it determines the JSON type (string, number, integer, boolean, null, array, or object). Objects are described with properties and optionally a required array. Arrays are described with an items schema that represents the type of elements. When an array contains elements of different types, the generator uses anyOf to represent the union of those types. You can optionally include empty description fields for documentation purposes, or include examples fields that use the actual values from your input data as sample values.
FAQ
Q: What JSON Schema draft versions are supported?
A: This tool supports Draft-04, Draft-06, Draft-07, 2019-09, and 2020-12. Draft-07 is selected by default as it is the most widely adopted version. The main differences between versions involve the $schema URI and certain keywords. For example, 2020-12 uses prefixItems instead of tuple-style items from earlier drafts.
Q: How does it handle nested objects?
A: The generator recursively traverses every level of nesting in your JSON. Each nested object gets its own properties and required definitions within the parent schema. There is no depth limit, so deeply nested structures are fully supported.
Q: Can it detect array item types?
A: Yes. For arrays where all elements share the same type, the generator produces a single items schema for that type. For arrays with mixed types (for example, strings and numbers), it uses anyOf to list all distinct types found. For arrays of objects, it merges properties from all objects to create a comprehensive item schema.
Q: What about null values?
A: Null values are represented as {"type": "null"} in the generated schema. If a field could be either a specific type or null, you can manually adjust the schema to use anyOf with the type and null, or use the nullable pattern depending on your draft version.
Q: Is my data processed locally?
A: Yes, completely. All schema generation happens in your browser using JavaScript. No data is sent to any server. You can verify this by checking the Network tab in your browser's developer tools while using the tool.