JSON Schema Generator

Automatically generate JSON Schema from sample JSON data. Supports Draft 2020-12 and Draft-07 with type inference and format detection.

What is JSON Schema Generator?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It describes the structure, type constraints, and validation rules for JSON data. This tool automatically generates a JSON Schema from sample JSON data by inferring types, detecting formats, and identifying required fields — saving you from writing schemas by hand.

How to Use

  1. Paste your sample JSON data into the input panel.
  2. Choose a schema version: Draft 2020-12 (latest) or Draft-07 (widely supported).
  3. Toggle 'All fields required' to mark every field as required, or leave it off to only mark non-null fields.
  4. Toggle 'Strict mode' to set additionalProperties: false, preventing extra fields.
  5. Click 'Generate Schema' to produce the JSON Schema.
  6. Copy the output and use it for validation, documentation, or code generation.

Why Use This Tool?

Automatic type inference: string, number, integer, boolean, null, array, object
Format detection for common patterns: email, URI, UUID, date-time, date, IPv4
Recursive handling of nested objects and arrays
Array item schema merging across multiple elements
Support for both Draft 2020-12 and Draft-07
Client-side processing — your data never leaves the browser

Tips & Best Practices

  • Use a representative sample with multiple array elements to get a more accurate merged schema for array items
  • Format detection is based on pattern matching — review detected formats and adjust if needed
  • For production schemas, consider adding validation keywords like minLength, maxLength, pattern, minimum, maximum
  • Draft 2020-12 is the latest standard, but Draft-07 has broader tooling support
  • Strict mode is useful for API contracts where extra fields should be rejected

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, type, and constraints of JSON data. JSON Schema is used for validation, documentation, and code generation in APIs and applications.

What JSON Schema versions are supported?

This tool supports both Draft 2020-12 (the latest standard) and Draft-07. Draft 2020-12 uses $schema: "https://json-schema.org/draft/2020-12/schema" and Draft-07 uses $schema: "http://json-schema.org/draft-07/schema#". The main difference is that Draft 2020-12 replaces items with prefixItems for tuple validation and introduces new keywords.

How does format detection work?

The generator inspects string values and detects common formats like email, URI, UUID, date-time, date, and IPv4 addresses using pattern matching. Detected formats are added as the "format" keyword in the schema, enabling validators to perform additional checks beyond structural validation.

What does strict mode do?

Strict mode sets additionalProperties: false on all object schemas. This prevents any properties not defined in the schema from being accepted during validation. Without strict mode, additional properties are allowed by default.

How are array item schemas generated?

The generator inspects all elements in an array and merges their schemas. If all elements have the same type, a single items schema is produced. If elements have different types, a merged schema with multiple types is generated. This provides a more accurate schema than just using the first element.

Is my data secure?

Yes. All schema generation is performed entirely in your browser using JavaScript. Your JSON data is never sent to any server, never stored, and never logged.

Related Tools