JSON Schema Generator Online - Generate Schema from JSON
Generate JSON Schema from your JSON data. Supports draft-04, draft-07, and 2020-12. Perfect for API documentation and data validation.
data_object Input JSON
code Generated JSON Schema
Click Generate Schema to create a JSON Schema from your JSON input.
Key Features
Multi-Version Support
Generate schemas in draft-04, draft-07, or 2020-12 format.
Accurate Type Detection
Automatically detects object, array, string, number, boolean, and null types.
Nested Object Handling
Properly generates schema for deeply nested JSON structures with $defs support.
Privacy Safe
All processing runs locally in your browser. No data upload needed.
Frequently Asked Questions
Getting Started
What is a JSON Schema?
JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It describes the structure, constraints, and data types of JSON data.
What schema versions are supported?
The tool supports draft-04, draft-07, and 2020-12. Draft-07 is recommended for most use cases.
Features & Usage
Can I generate schema from any JSON?
Yes. The tool accepts any valid JSON and generates an appropriate schema. Complex nested objects and arrays are handled automatically.
Is the generation lossless?
The generated schema accurately represents the structure of your input JSON. However, since JSON alone cannot express constraints like minimum/maximum values or regex patterns, those will not be included.
How do I use the generated schema?
The generated schema can be used with any JSON Schema validator library in your programming language of choice to validate JSON data against the expected structure.
What is if-then-else in JSON Schema?
If-then-else (draft-07+) allows conditional validation. If the schema in "if" validates, then "then" must also validate; otherwise "else" must validate. For example: if an object has a "price" field that must be a number, then require a "currency" field.
What is additionalProperties in JSON Schema?
additionalProperties controls whether extra properties beyond those defined in "properties" are allowed. Set to false to reject unknown keys. In 2020-12, unevaluatedProperties provides even more flexible control over property validation.
What is the difference between JSON Schema and OpenAPI/Swagger?
JSON Schema describes JSON data structure for validation. OpenAPI (formerly Swagger) is a full API specification format that uses a subset of JSON Schema to describe request/response bodies. OpenAPI 3.0 uses JSON Schema draft-07 with some restrictions. OpenAPI 3.1 fully aligns with JSON Schema 2020-12.
What is the difference between draft-04, draft-07, and 2020-12?
draft-04 was the first widely adopted version (2013). draft-07 (2018) added if/then/else, $comment, and contentMediaType. 2020-12 is the latest with $defs replacing definitions, unevaluatedProperties, prefixItems for tuple validation, and improved vocabulary extensibility. draft-07 is the most widely supported for tooling.
Troubleshooting
What if my input is not valid JSON?
The tool will display an error message indicating the JSON parse error. Please check your JSON syntax and try again.
Can I use this tool offline?
Yes. Once you have visited the page, all functionality works offline thanks to local processing.
Is my data safe when using this tool?
Yes. All processing happens locally in your browser. Your JSON data never leaves your device. No upload is needed.
Advanced Topics
How does oneOf, anyOf, and allOf differ in JSON Schema?
oneOf requires exactly one of the listed sub-schemas to validate successfully, anyOf allows one or more sub-schemas to match, and allOf requires every sub-schema to pass simultaneously. For example, oneOf is ideal for discriminated unions like "paymentMethod" accepting either "credit_card" or "paypal", while allOf is used for schema composition and extending base definitions.
What is the $ref keyword and how does it support schema reuse?
$ref allows referencing other schema definitions using JSON Pointer syntax, enabling DRY schema design. For example, "$ref": "#/$defs/address" points to a reusable address definition within the same schema. In draft-04 and draft-07, definitions go under "#/definitions/", while 2020-12 uses "#/$defs/" for this purpose. External $ref can also reference remote schema files.
Can JSON Schema enforce cross-field validation like date range checks?
JSON Schema alone cannot express cross-field constraints like "endDate must be after startDate" because each property is validated independently. Draft-07 introduced if-then-else for some conditional logic, but arbitrary cross-field comparisons require external validation in your application code. Use JSON Schema for type and structure validation, then add business rules programmatically.
How does 2020-12 handle array tuple validation vs earlier drafts?
In 2020-12, tuple validation uses the prefixItems keyword as an array of schemas where each position corresponds to an array element index. The items keyword (now unevaluatedItems in 2020-12) serves as a fallback for remaining elements beyond the tuple. This separation provides clearer semantics than draft-07 where items served dual purposes for both tuple and item validation.
What is the difference between JSON Schema and JSON Type Definition (RFC 8927)?
JSON Type Definition (JTDF, RFC 8927) is a simpler, more restricted schema format designed specifically for HTTP APIs and protocol buffers. It supports fewer keywords than JSON Schema but is easier to implement and validate. JSON Schema is more expressive with conditional validation, pattern matching, and cross-references, while JTDF prioritizes simplicity and unambiguous type definitions.
Last updated: July 14, 2026
JSON Schema is maintained by the JSON Schema organization. See also Understanding JSON Schema and the JSON Schema IETF drafts.