Paste any JSON and instantly generate a valid JSON Schema (draft-07). Infers types, required fields, nested objects, and array items.
JSON Formatter, JSON to TypeScript, and 40+ more free developer tools.
Browse All Tools →JSON Schema is a vocabulary that allows you to validate and describe the structure of JSON data. It's widely used in API documentation (OpenAPI/Swagger), form validation, configuration files, and data interchange.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 },
"email": { "type": "string", "format": "email" }
},
"required": ["name", "email"]
}
This tool automatically detects common string formats:
JSON Schema is a vocabulary for annotating and validating JSON documents. It defines the structure, data types, and constraints of a JSON object. It's used for API request/response validation, form input validation, documentation generation, and ensuring data contracts between services. Tools like Ajv, OpenAPI, and Postman use JSON Schema natively.
TypeScript interfaces provide compile-time type checking in JavaScript codebases. JSON Schema provides runtime validation that works in any language or environment. JSON Schema can validate actual data values against constraints like minimum, maximum, pattern, and enum. TypeScript interfaces are erased at runtime; JSON Schema persists and can validate data from external sources.
Use JSON Schema Draft-07 or Draft 2020-12 for new projects. Draft-07 has the widest library support. Draft 2020-12 is the latest standard with improved features like dynamic references and prefix items for arrays. Check your validation library's documentation for supported drafts. OpenAPI 3.0 uses a subset of Draft-07, while OpenAPI 3.1 uses Draft 2020-12.
Add a required array at the same level as your properties object, listing the field names that must be present: "required": ["id", "name", "email"]. By default, all properties in JSON Schema are optional. The required keyword validates presence, not value — the field must exist but can be null unless you also constrain the type.
Yes. Use the items keyword to define the schema for array elements. For nested objects, use type: object with its own properties and required arrays. You can nest schemas as deeply as needed. Use $ref to reference reusable sub-schemas defined in the $defs section, keeping your schema DRY and maintainable.