Skip to content
ToolsMinify logo
Developer Tools

JSON Schema Generator

Generate a draft JSON Schema from a JSON sample in your browser - no account, no upload, no CLI.

About JSON Schema Generator

Generate a draft JSON Schema from a JSON sample in your browser - no account, no upload, no CLI. Paste an API response or, better, an array of records. Nested objects become nested schemas, arrays are typed from every element (not only the first), and identical missing-key patterns become optional (omitted from required). JSON null becomes a nullable type instead of collapsing into optional. String formats are inferred when values look like email, uri, uuid, date, or date-time. Choose Draft-07 or 2020-12, then copy or download the schema. Pair it with the JSON to TypeScript Converter for interfaces from the same sample, or the JSON Minifier if the payload arrived minified.

How to Use JSON Schema Generator

  1. Paste JSON (an array of records infers optional keys more accurately than a single object). Load a sample if you want to see optional vs nullable first.
  2. Set the schema title and pick Draft-07 (default) or 2020-12. Choose whether objects reject or allow additional properties.
  3. Read the inference report: property count, required keys, optional keys, and format hints. Warnings flag empty arrays, empty objects, all-null fields, and mixed unions.
  4. Copy the JSON Schema or download a .schema.json file. Use it in AJV, Zod (via converters), OpenAPI drafts, or CI validators.
  5. Nothing is sent to a server. Invalid JSON reports a line and column.

JSON Schema Generator Examples

Optional key from an array of records

[{"sku":"A1","qty":2},{"sku":"B7","qty":1,"gift":true}] becomes an array schema whose items require sku and qty, while gift is optional (not in required).

Nullable vs optional

Two users where email is missing on one row and note is null on the other emit email as optional string and note as type ["string","null"]. Missing keys and JSON null stay distinct.

String format hints

Values that look like emails, https URLs, UUIDs, ISO dates, or date-times get format: email, uri, uuid, date, or date-time so validators can enforce them.

Empty containers

{"items":[],"meta":{}} types items as an array with empty items schema and meta as an object with no properties. Warnings tell you to paste a richer sample.

Draft-07 vs 2020-12

Both drafts share the same inferred shape. Draft-07 uses the classic $schema URI most tooling still expects. Switch to 2020-12 when your stack documents that dialect.

Common Use Cases

  • Drafting a JSON Schema before the OpenAPI / AsyncAPI spec exists
  • Validating webhook payloads (Stripe, GitHub, Slack) in CI with AJV
  • Turning a fixture file into a contract for contract tests
  • Bootstrapping schema for config files and feature-flag payloads
  • Pairing with TypeScript interfaces from the same sample JSON

Frequently Asked Questions about JSON Schema Generator

How do I generate a JSON Schema from sample JSON?
Paste a JSON sample, set a title, pick a draft, and copy the generated schema. Generation runs in your browser. Nested objects and arrays are walked fully, and keys missing across array items are omitted from required.
What is the difference between optional and nullable?
Optional means the key was absent on some array items, so it is not listed in required. Nullable means the key was present and the value was JSON null, so the type includes null (for example type: ["string","null"]). This generator does not collapse them unless the sample showed both.
Which JSON Schema draft should I use?
Draft-07 is still the most widely supported by validators and editors. Use 2020-12 when your tooling explicitly expects that $schema URI. The inferred properties are the same either way.
Why is items or properties empty?
Empty arrays have no elements to inspect, so items is {}. Empty objects have no keys, so properties is empty. Paste a populated example to get concrete types.
Are string formats always correct?
Formats are heuristics from the sample values (email, uri, uuid, date, date-time). Review them before locking a production contract - a string that looks like an email in the sample may not always be one.
Is my JSON uploaded?
No. Schema generation runs only in this tab. The sample never leaves your browser.
How is this different from the JSON to TypeScript converter?
Both walk the same kind of sample. This page emits JSON Schema for validators and OpenAPI drafts. The TypeScript converter emits interfaces or type aliases for application code. Use both from the same payload when you need a contract and typed clients.
Does additionalProperties: false reject unknown keys?
Yes when you leave Reject extras on. That is useful for strict API contracts. Switch to Allow extras if clients may send fields you have not seen in the sample yet.