Command Palette

Search for a command to run...

JS

JSON Schema Generator

Generate a JSON Schema from any JSON sample. Infers types, merges arrays of objects into one item schema, derives required fields, and detects date-time, email, uri, and uuid formats. Draft-07 and 2020-12 output. 100% client-side.

Dialect:
Category:data
Mode:Offline
Version:1.0.0
Access:Free

What is the JSON Schema Generator?

JSON Schema Generator interface on Toolz.dev - Generate a JSON Schema from any JSON sample. Infers types, merges arrays of objects into one item schema, derives required fields, and detects date-time, email, uri, and uuid formats. Draft-07 and 2020-12 output. 100% client-side.

The JSON Schema Generator reads a sample JSON value - an API response, a config file, a webhook payload - and writes a JSON Schema that validates it. It infers the type of every field, merges an array of objects into a single item schema rather than a noisy union, derives which keys are required from the ones present in every record, and can tag string formats like date-time, email, uri and uuid. You paste data you already have; you get the schema you would otherwise hand-write clause by clause.

Writing a schema by hand is slow and easy to get subtly wrong. It is tempting to type what you think a payload contains, miss a nested field, mark an occasionally-null property as required, or forget that one endpoint returns an array where another returns a single object. A schema generated straight from real data starts from the actual shape, so the document you validate against matches what the service genuinely sends. From there you tighten constraints - patterns, enums, minimums - by hand, but the tedious scaffolding is done.

Everything runs in your browser. The inference engine is dependency-free TypeScript, not a wrapper around a hosted API, so payloads - which routinely carry tokens, emails and internal IDs - never leave the page. Choose Draft-07 or the 2020-12 dialect, add a title, toggle required-field detection, format detection and strict `additionalProperties`, then copy the schema or download it as a .json file.

The schema describes your sample rather than your intent, so treat the output as a first draft: required fields are inferred from what happens to be present, and formats are detected by pattern, so a string that looks like a date is typed as one even when it is an identifier that merely resembles one.

Here is a worked example of the JSON schema generator from JSON with more than one record. Paste [{"id":1,"email":"[email protected]","nick":"x"},{"id":2,"email":null}] and press Generate. The output is an array schema whose items have id as integer, email as ["string", "null"] and nick as string, with required set to id and email, because nick is missing from the second record. The header reads 3 properties, 2 required, depth 2, 219 bytes. That is the job of any JSON to JSON schema generator: every record you add can widen a type or drop a key from required.

How to use the JSON Schema Generator?

1

Paste your JSON

Drop in an API response, a fixture, or any JSON value. Load the sample first to see how nested objects, arrays of objects and string formats are handled.

2

Pick the dialect

Choose Draft-07 for the widest tooling support or 2020-12 for the current specification. The correct $schema URI is written onto the output for you.

3

Set your options

Add an optional title, decide whether to emit a required array, detect string formats, and lock objects down with additionalProperties: false for strict validation.

4

Generate, then copy or download

Press Generate. Review the inferred types and required fields, then copy the schema to your clipboard or download it as a .json file ready to drop into your validator.

Key Features

Draft-07 and 2020-12 output

Emit either the widely-supported Draft-07 dialect or the current 2020-12 specification. The matching $schema identifier is written onto the root so validators pick the right rules.

Smart array merging

An array of objects becomes a single items schema describing one element, not a sprawling anyOf. Keys present in every element are required; keys that appear in only some are left optional.

Required-field inference

The generator derives the required array from keys present in every object it sees, which is exactly how real paginated data behaves - some fields are always there, others are not.

String format detection

Recognises date-time, date, time, email, uri, uuid and ipv4 strings and tags them with the appropriate format keyword, giving you validation you would otherwise add by hand.

Frequently Asked Questions

Paste your JSON into the editor, pick Draft-07 or 2020-12, and press Generate. The tool infers the type of every field, extracts the required keys, and outputs a schema you can copy straight into a validator. Nothing is uploaded - inference runs entirely in your browser.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

json schema generatorjson to json schema generatorjson schema generator from jsonjson to schema generatorjson to json schema generator onlinegenerate json schemajson to json schemajson schema from jsonjson schema draft-07json schema 2020-12infer json schemajson validation schemajson schema builder