Developer Tools
JSON Schema Generator
Generate a JSON Schema from any JSON sample in your browser. Draft 7 and 2020-12, format detection, required keys, examples, and nested object inference.
Schema options
Live preview updates with every change. All inference happens in your browser; the JSON you paste is not uploaded.
Schema draft
Sets the $schema URI at the top of the document.
Required keys
Emitted as the top-level "title" field. Leave blank to omit.
Sets a stable identifier so other schemas can $ref this one.
How inference works
Type detection
Whole-number JS values become integer; numbers with a decimal part become number. null becomes its own type so a column of maybe-null values widens to ["string", "null"].
Object merging
Sibling objects (for example, every element of an array of objects) are merged into one shape. A key seen in every sibling is required by default; a key seen in only some siblings is optional.
Array items
Every array element contributes to a single items schema. Mixed primitive arrays produce a type array such as ["string", "number"].
Format detection
Strings are tagged with a format only when every observed value matches the same pattern, so a single non-matching value disables the label and keeps the schema honest.
How to use
- Paste a JSON sample into the input on the left, or click Load sample JSON to see a worked example.
- Pick a schema draft (Draft 7 for OpenAPI 3.0 and Ajv, or 2020-12 for OpenAPI 3.1) and a required-keys policy that matches how strict your validator should be.
- Set a Root title (and optional $id) so the schema can be referenced from other documents with $ref.
- Toggle Detect string formats to tag uuid, email, date, date-time, time, ipv4, ipv6, and uri fields, or Include examples to attach observed values to each primitive field.
- Click Copy schema to put the full JSON Schema on your clipboard, ready to paste into an OpenAPI spec, an Ajv schema file, or a JSON Schema directory.
About this tool
JSON Schema Generator turns a JSON sample into a clean JSON Schema document entirely in your browser. Paste an API response, a config file, a fixture, or any copied object literal, and the tool parses it with the browser's native JSON parser, walks the resulting tree, and emits a JSON Schema you can drop into an OpenAPI spec, an Ajv validator, a contract test, or a code generator. Inference is structural: whole-number values become integer, decimal values become number, null becomes its own type so a column of maybe-null values widens to a type array like [string, null], and sibling objects (for example, every element of an array of objects) are merged into one shape so the same key is described once. The required field defaults to keys that appeared in every observed sibling and ignores keys that appeared in only some, so the schema reflects what the sample actually proves; you can also switch to all keys required, no keys required, or omit the required field entirely. Format detection is opt-in and conservative: a string field is tagged with format only when every observed value matches the same pattern, covering uuid, email, date, date-time, time, ipv4, ipv6, and uri. Output options control the schema draft (Draft 7 for OpenAPI 3.0 and Ajv defaults, or 2020-12 for OpenAPI 3.1 and modern validators), whether unexpected keys are allowed (additionalProperties), whether observed values are emitted as examples, and whether the document is pretty-printed or compacted. The root document carries an optional title and an optional $id so other schemas can reference this one with $ref. Useful for typing API responses without hand-writing a schema, generating contract tests from real fixtures, scaffolding OpenAPI components, validating webhook payloads with Ajv, sharing a schema with a frontend team, and saving time on every Pull Request that adds a new endpoint. Parsing and inference run locally on your device, so the JSON you paste here never leaves your browser.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
JSON Formatter
Format, minify, and validate JSON in your browser.
Open tool
DeveloperJSON to TypeScript Converter
Generate TypeScript interfaces or types from any JSON value with full inference.
Open tool
DeveloperJSONPath Tester
Evaluate JSONPath queries with filters, regex, and recursive descent.
Open tool
ConverterYAML to JSON Converter
Two-way YAML and JSON converter with anchors, flow, and block scalars.
Open tool