JSON Schema Generator
Runs 100% in your browserGenerate a reviewable JSON Schema from a JSON sample locally. Infer nested objects, arrays, required fields, nullable values, common formats, additionalProperties, and draft metadata — copy or download the result. No upload, no account.
Sample document
Generated schema
Recent generations
Frequently asked questions
A JSON Schema Generator creates a JSON Schema document from an example JSON value. It infers types, object properties, array items, required-field candidates, common string formats, nullability, and additional-property rules so you can begin documenting or validating an API payload, configuration file, or webhook body.
Paste a valid JSON object or array into the input panel, choose a draft version, set required-field and nullability options, optionally enter a title or $id, and the schema is generated live. You can copy the result or download it as a .schema.json file.
The generator can emit Draft 2020-12, Draft 2019-09, Draft 7, Draft 6, and Draft 4 $schema identifiers. Draft 7 is the default and is supported by most common validators. Switching the selector updates the $schema URI in the output immediately.
In All observed properties mode, every object key seen in the sample is added to a required array. You can choose No inferred required fields when the sample is partial or when required fields should be determined manually. A single sample cannot prove which properties will always appear in production payloads.
Yes. Nested objects receive recursive properties schemas, and arrays receive items schemas. When an array contains multiple observed types, the generator merges them into a union type. Empty arrays are handled by either leaving items unspecified or emitting an open item schema, because an empty array provides no evidence about its element type.
Yes. If the root value is an array the generator infers an items schema by merging all element schemas. This covers homogeneous arrays of objects and heterogeneous arrays of primitives. The result is a root-level schema with type:array and a merged items definition.
When Preserve nullability is enabled, a JSON null value is emitted as type:null. If null appears alongside a non-null sibling of the same key in merged arrays, both types are represented. Confirm the intended nullable contract for each field before production.
When Infer formats is enabled, the generator recognises email, date, date-time, time, UUID, URI (http/https), and IPv4. Format inference is heuristic — a sample string may match a format pattern accidentally — so review each inferred format against the real contract.
When additionalProperties: false is enabled, the generated schema will reject any instance object with keys not declared in properties. This creates a strict contract but can cause validation failures if the API later adds new fields. Disable it when you want an open object contract.
Yes. Enter a title in the Title field and an optional $id URI. The generator adds a review description automatically and places $schema, $id, title, and description first in the output. A stable $id should match your project URI strategy rather than a placeholder.
The generator focuses on readable inline nested properties rather than automatic $defs deduplication. It does not generate a $ref graph or extract repeated sub-schemas into a definitions block. For complex schemas with shared definitions, review and refactor the output with a schema editor after generation.
The generator creates a schema from a sample JSON document. The validator checks a JSON instance against an existing schema. The typical workflow is generate → review and edit → validate several real instances. Both tools are available on ToolsSonic and link to each other.
quicktype supports multiple source types and generates language bindings from schemas, making it a broad multi-language workflow tool. JSONSchema.net is a configurable web app with a schema editor, REST API, and CLI. ToolsSonic focuses on a single approachable browser workspace with draft choice, nullable, formats, required-field and additionalProperties controls, statistics, and private local processing — no upload, no account, no install.
It is a starting point, not a guaranteed contract. Test the generated schema against multiple representative payloads, review required arrays, confirm nullability and format inference, add business rules and constraints, and validate it with the target JSON Schema library or validator.
Yes. Copy schema places the JSON Schema text on the clipboard, and Download .schema.json saves a local file named after the title you entered. Both actions happen in the browser.
No. The generator parses and processes JSON entirely in your browser. It does not upload the input, call a remote schema service, or persist documents in localStorage or sessionStorage. Clipboard access and shared-device privacy remain separate considerations.
The generator stops before inference and shows the browser parser error message. Use JSON Validator or JSON Repair to locate the syntax problem, then generate the schema again after the input parses successfully.
Yes. Press Ctrl+Enter (or Cmd+Enter on Mac) to re-run generation after changing settings. The schema updates live as you type in the input textarea, so manual regeneration is mainly useful after modifying settings like draft, title, or options.
The stats strip shows input bytes, schema bytes, inferred property count, array count, total nodes processed, and maximum nesting depth. These help you quickly understand the shape of your sample and the resulting schema size.
What is JSON Schema Generator?
What Is a JSON Schema Generator?
A JSON Schema Generator infers a reviewable JSON Schema from a sample JSON document. It analyses each value in the sample and emits a schema with object properties, type, required candidates, items for arrays, nullability, common format annotations, and additionalProperties control — ready for review, editing, and production hardening.
JSON Schema is the machine-readable contract that JSON Schema validators and OpenAPI tools enforce. Generating a first draft from a sample document saves hours compared to writing properties, type, and required arrays by hand. The generated schema is a starting point, not an automatic proof: a single sample cannot prove which fields are always present, what business constraints apply, or whether future API versions will introduce new keys.
How ToolsSonic's JSON Schema Generator Works
Five drafts, one selector. Draft 2020-12, 2019-09, 7, 6, and 4 are all supported. Switching the Draft dropdown immediately updates the $schema URI in the output. Draft 7 is selected by default because it is the most widely supported by validators, OpenAPI 3.0 tooling, and JSON Schema libraries including Ajv, jsonschema, and tv4.
Required-field heuristics. Choose *All observed properties* to mark every key seen in the sample as required — the strictest starting point — or choose *No inferred required fields* when the sample is partial and required fields need manual specification.
Null handling. When *Preserve nullability* is on, a JSON null value becomes {"type":"null"}. This is the correct output: NextJSON incorrectly maps null to type:object. ToolsSonic uses the JSON specification's actual null type, which downstream validators and TypeScript generators handle correctly.
Format inference. Heuristic detectors recognise email, date, date-time, time, uuid, uri, and ipv4. Format annotations are advisory in JSON Schema — they do not cause validation failures unless the validator is configured to enforce them — so they are safe to include and easy to remove.
additionalProperties: false. Turning this on creates a strict object contract that rejects any property not listed in the schema. This is useful for API boundary enforcement but may need relaxing for evolving APIs.
JSON Schema Generator vs Validator — When to Use Each
The generator and the validator are the two halves of a JSON Schema workflow:
1. Generate — paste a sample JSON document and get a first-draft schema with inferred types, required fields, and format annotations.
2. Review and edit — adjust required arrays, add business constraints, remove over-inferred formats, decide on additionalProperties, and set a meaningful $id.
3. Validate — run real production payloads through the JSON Schema Validator to check the finalized schema against actual data.
Public competitor research showed that NextJSON provides a simple generate workflow with limited nullability and no metadata controls. quicktype targets multi-language code generation from JSON samples. JSONSchema.net is a powerful CLI/API tool with a steep learning curve. ToolsSonic fills the gap between a one-click generator and a technical library: five draft versions, nullable, formats, required heuristics, additionalProperties, title and $id, structure statistics, copy and download — all private, all in the browser, zero install.
Common use cases
- Creating a first-draft schema from an API response sample or webhook body
- Documenting configuration file structure with required fields and type constraints
- Generating nested object and array schemas from multi-level JSON payloads
- Choosing strict or open additionalProperties behavior for an API contract
- Adding title, description, $id, and draft metadata for OpenAPI or JSON Schema tooling
- Recognising common email, date, date-time, UUID, and URI formats automatically
- Generating a schema and then validating multiple real instances against it
- Copying or downloading a local .schema.json file for a project or team review
Why use ToolsSonic's JSON Schema Generator?
ToolsSonic's JSON Schema Generator combines the simplest local workflow with the controls that address gaps in lightweight generators: Draft 2020-12, 2019-09, 7, 6, and 4 metadata; title and optional $id; all-observed or no-inferred required fields; correct null→type:null handling; common format inference for email, date, date-time, time, UUID, URI, and IPv4; empty-array strategies; additionalProperties: false; readable inline nested schemas; pretty or compact output; copy and download; local file input; six live statistics; and invalid-JSON diagnostics. No upload, no account, no install.
How JSON Schema Inference Works — Step by Step
When you paste a JSON document and click Generate, the engine recursively walks every value:
Objects → emit {"type":"object","properties":{...}} with a recursive sub-schema for each key. If *All observed properties* is selected, a required array lists every key. If additionalProperties: false is on, the keyword is added to prevent unknown keys.
Arrays → emit {"type":"array","items":{...}} where items is the merged schema of all array elements. Heterogeneous arrays produce a type union such as {"type":["string","number"]}. Empty arrays cannot be inferred and are emitted as {"type":"array"} or {"type":"array","items":{}} depending on the empty-array setting.
Strings → emit {"type":"string"} plus an optional "format" annotation when format inference recognises a pattern (email, date, UUID, URI, etc.).
Numbers → emit {"type":"integer"} when the value has no fractional part, or {"type":"number"} otherwise.
Booleans → emit {"type":"boolean"}.
Null → emit {"type":"null"} when *Preserve nullability* is on, or an empty schema {} when off.
After inference the engine prepends $schema, $id (if set), title, and description to the output object so the most important metadata appears at the top of the file. The result is pretty-printed at 2-space indentation by default or compacted when *Pretty print* is off.
Inferred Formats Reference
The format inference step runs only when *Infer formats* is enabled. Each detector is a regex heuristic applied to string values only:
| Format | Pattern matched |
|--------|----------------|
| email | Non-whitespace characters on both sides of @ with a dot in the domain |
| date-time | ISO 8601 combined date and time with optional timezone |
| date | YYYY-MM-DD pattern |
| time | HH:MM:SS with optional fractional seconds and timezone |
| uuid | RFC 4122 8-4-4-4-12 hexadecimal UUID |
| uri | String beginning with http:// or https:// |
| ipv4 | Four dot-separated octets each 0–255 |
Formats are annotations in JSON Schema — they do not cause validation failures unless the validator is explicitly configured to enforce them. Review every inferred format against the real data contract before finalising the schema.
Related tools
JSON Schema Validator
Editor's choiceValidate a JSON instance against a JSON Schema locally — Draft 4/6/7 and 2020-12 common subset, path-aware errors by keyword, type, format, required, composition, and local $refs. 100% browser-only, no upload.
JSON to TypeScript Interface
Editor's choiceConvert JSON to TypeScript interfaces, type aliases, or enums in your browser. Infer nested objects, arrays, unions, readonly modifiers, optional and nullable fields, safe names, and downloadable .ts definitions from any JSON sample.
JSON Validator
Editor's choiceValidate JSON online with precise line and column diagnostics, targeted repair hints, structure inspection, and browser-only processing — no upload, no account.
JSON Formatter
Editor's choiceFormat, beautify, minify, and validate JSON locally. Choose indentation, sort keys, preserve Unicode, inspect statistics, and copy or download clean output.
JSON Editor
Editor's choiceEdit JSON online in a private browser-based editor with line numbers, live validation, syntax-aware formatting, key sorting, Unicode support, search, and local export — nothing uploaded.
JSON Path Tester
Editor's choiceTest JSONPath expressions against any JSON document instantly. Evaluate wildcards, recursive descent, filter expressions, slices, negative indexes, and compound &&/|| filters — all private, all in your browser.