100% FREE · NO SIGNUP

JSON Schema Generator

Paste any JSON and instantly generate a valid JSON Schema (draft-07). Infers types, required fields, nested objects, and array items.

Sample Data

Options

JSON Input
JSON Schema Output
0 properties
0 required
0 nested objects
0 lines

🚀 More Free Dev Tools

JSON Formatter, JSON to TypeScript, and 40+ more free developer tools.

Browse All Tools →

What Is JSON Schema?

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.

Why Use JSON Schema?

JSON Schema Example

{
  "$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"]
}

Format Detection

This tool automatically detects common string formats:

Frequently Asked Questions

What is JSON Schema and what is it used for?

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.

What is the difference between JSON Schema and TypeScript interfaces?

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.

What JSON Schema version should I use?

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.

How do I mark fields as required in JSON Schema?

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.

Can I use JSON Schema to validate nested objects and arrays?

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.

Related Free Tools

JSON Formatter JSON to TypeScript JSON Diff JSON Path Finder YAML to JSON