JSON Schema Generator

Generate JSON Schema (draft-07) from sample JSON data automatically. Detects types, patterns (email, URI, date, UUID, IP), nested objects, and arrays. Add titles, descriptions, and mark required fields.

JSON Data

JSON Schema (draft-07)

Features

🔎

Automatic Type Detection

Automatically detects string, number, integer, boolean, null, array, and object types from your JSON data. No manual configuration needed.

📝

Pattern Recognition

Detects common string patterns like email, URI, date-time, UUID, and IP addresses. Adds appropriate format constraints to your schema.

🔗

Nested Structures

Handles nested objects and arrays of any depth. Generates complete property schemas for complex, hierarchical data structures.

Required Fields

Toggle whether all fields should be marked as required. Customize which properties are mandatory for validation.

About JSON Schema

JSON Schema is a powerful vocabulary for validating the structure of JSON data. It allows you to define the expected shape, types, constraints, and metadata of your JSON documents. JSON Schema is widely used in API development for request/response validation, in documentation tools like Swagger/OpenAPI, in form generation libraries, and in data integrity checks across distributed systems. By defining a schema, you create a contract that ensures data consistency and catches errors early in the development process.

Why Generate Schema from Data?

Writing JSON Schema by hand is time-consuming and error-prone, especially for complex, nested structures. This tool automates the process by analyzing sample JSON data and inferring the schema. It detects types, identifies common patterns (emails, URLs, dates), handles nested objects and arrays, and generates a complete, valid JSON Schema draft-07 document. This saves hours of manual work and ensures your schema accurately reflects your data structure. You can then refine the generated schema by adding additional constraints like minimum/maximum values, string length limits, enum values, or custom patterns.

How This Tool Works

Paste your sample JSON data into the input field. The tool parses the JSON, examines each property, and infers the appropriate type. For strings, it checks against known patterns (email regex, URI format, ISO date format, UUID format, IP address format). For numbers, it determines if they are integers or floats. For arrays, it checks all elements to see if they share a common type. For nested objects, it recursively generates property schemas. The result is a complete JSON Schema with $schema, type, properties, and optionally title, description, and required fields. You can copy the schema to your clipboard or download it as a .json file.

Common Use Cases

Frequently Asked Questions

What is JSON Schema?
JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It describes the structure, data types, required fields, and constraints of your JSON data. JSON Schema is used for API documentation, data validation, form generation, and ensuring data integrity. It's a powerful tool for defining contracts between systems and validating incoming data against expected formats.
What is JSON Schema draft-07?
Draft-07 is one of the most widely supported versions of JSON Schema. It includes features like if/then/else conditionals, readOnly and writeOnly properties, and improved string format validation. This tool generates schemas using the draft-07 specification, indicated by the $schema property: http://json-schema.org/draft-07/schema#. While newer drafts exist (2019-09, 2020-12), draft-07 has excellent library support and is used by many APIs and tools.
How does automatic type detection work?
This tool examines each value in your JSON data and infers its type. Strings are analyzed for patterns: emails (user@example.com), URIs (https://...), dates (ISO 8601), UUIDs, and IP addresses. Numbers are classified as integer or number based on whether they have decimal points. Booleans, null, arrays, and objects are detected directly. For arrays, the tool examines all elements to determine if they have a consistent type or are mixed.
What are required fields in JSON Schema?
The required keyword in JSON Schema specifies which properties must be present in an object. For example, if your schema has required: ['name', 'email'], then any JSON data validated against this schema must include both name and email properties. This tool allows you to toggle which fields are required. By default, it marks all top-level fields as required, but you can customize this based on your validation needs.
How do I handle nested objects and arrays?
This tool automatically handles nested structures. For nested objects, it generates a properties schema for each object with its own type definitions. For arrays, it detects whether all elements are the same type and generates an items schema accordingly. For example, an array of objects will have items: { type: 'object', properties: {...} }. Mixed-type arrays are not recommended in JSON Schema but are detected as type: 'array' without specific items constraints.
What string patterns does this tool detect?
The tool detects common string patterns and adds the format keyword to your schema: email (user@example.com), uri or url (https://example.com), date-time (ISO 8601 dates), uuid (universally unique identifiers), ipv4 and ipv6 (IP addresses). These format keywords enable validators to check that string values match the expected pattern. For example, a field with format: 'email' will be validated to ensure it's a properly formatted email address.
Can I add titles and descriptions to the schema?
Yes, this tool provides options to add a title and description to the root schema. The title provides a short, human-readable name for the schema (e.g., 'User Profile Schema'). The description offers a longer explanation of what the schema represents. These are optional but recommended for documentation purposes, especially when sharing schemas with other developers or using them in API documentation tools.
How do I use the generated schema for validation?
Once generated, you can use the schema with JSON Schema validation libraries in any programming language. Popular libraries include ajv (JavaScript), jsonschema (Python), and json-schema (Ruby). Example in JavaScript: const Ajv = require('ajv'); const ajv = new Ajv(); const validate = ajv.compile(yourSchema); const valid = validate(yourData); if (!valid) console.log(validate.errors);. The schema ensures all data conforms to the expected structure and types.

Explore More Developer Tools

Check out our other free JSON tools. Format, validate, convert, and analyze JSON data with ease.

JSON Formatter →