Runs 100% in your browser — your JSON is never uploaded

JSON Schema Generator & Validator

Paste any JSON and get an accurate JSON Schema — Draft-04, Draft-07, 2019-09 or 2020-12 — with required fields, integer vs number, string formats and merged array items. Validate documents against it, or export as YAML or TypeScript.

Generate or validate a JSON Schema

JSON input

Waiting for JSON

JSON Schema

Your JSON Schema will appear here.

Schema settings

In short: what this JSON Schema generator does

The SeeB4Coding JSON Schema Generator infers a JSON Schema from a sample JSON document and validates JSON against any schema, entirely in your browser. Paste JSON, pick a draft, and copy the result — no sign-up, no upload.

  • Four drafts: Draft-04, Draft-07, 2019-09 and 2020-12, each with the correct $schema URI.
  • Accurate inference: integer vs number, null unions such as ["string", "null"], and nested objects and arrays to any depth.
  • Smart required fields: all array items are merged, so a key missing from any item stays optional.
  • Format detection: date-time, date, uuid, email, uri and ipv4.
  • Validator built in: lists every error with its JSON Pointer path, such as /orders/1/total.
  • Three outputs: JSON Schema, YAML (for OpenAPI files) and TypeScript interfaces.
  • Privacy: pure client-side JavaScript — your JSON never leaves the device.

How to generate a JSON Schema from JSON

Three steps, about a minute.

Paste your JSON

Paste an API response or config file, drop a .json file onto the editor, or load the sample. The status bar validates as you type and points at the exact line of any syntax error.

Choose a draft and options

Pick the JSON Schema draft your validator supports, set a title and $id, and toggle required detection, formats, strict additionalProperties and examples.

Copy, download or validate

Copy or download the schema as JSON, YAML or TypeScript, or switch to Validate JSON to test other payloads against it before you ship.

How JSON values map to JSON Schema

The inference rules the generator applies to every value in your sample.

JSON value to JSON Schema keyword mapping.
JSON value Generated schema Notes
"hello"{"type": "string"}Any text that matches no known format.
"2024-05-31T12:04:00Z""format": "date-time"RFC 3339 timestamp with a time zone. All drafts.
"2024-05-31""format": "date"Full calendar date. Draft-07 and later.
"3f1c9b7e-8d2a-…""format": "uuid"RFC 4122 UUID. 2019-09 and later.
"ada@example.com""format": "email"Also uri for https://… and ipv4 for 192.168.1.24.
42{"type": "integer"}Whole numbers. Emitted as number when integer detection is off.
4.2, or 40 and 129.5{"type": "number"}A key seen with both whole and decimal values is widened to number.
true{"type": "boolean"}—
null{"type": "null"}Becomes ["string", "null"] when the same key is a string elsewhere.
{ ... }"type": "object" + propertiesKeys present in every sample go into required.
[ {...}, {...} ]"type": "array" + itemsAll items are merged into one items schema.
[ "a", 1 ]"items": {"type": ["string", "integer"]}Mixed arrays produce a type union.
[]"items": {}An empty array gives no item type, so any item is allowed.

Which JSON Schema draft should you choose?

Pick the newest draft that every validator in your stack supports.

Differences between the JSON Schema drafts this tool generates.
Draft $schema URI What changed Typical use
Draft-04 http://json-schema.org/draft-04/schema# Uses id instead of $id, boolean exclusiveMinimum, no const or examples. Legacy validators, Swagger 2.0.
Draft-07 http://json-schema.org/draft-07/schema# Adds $id, const, examples, contains (from Draft-06) and if / then / else. The most widely supported draft across validators and editors.
2019-09 https://json-schema.org/draft/2019-09/schema Adds $defs, dependentRequired, dependentSchemas, unevaluatedProperties and $anchor. Schemas that compose and extend other schemas.
2020-12 https://json-schema.org/draft/2020-12/schema Replaces tuple items with prefixItems, adds $dynamicRef. New projects and OpenAPI 3.1.

Getting an accurate schema

A generated schema describes the shape of your sample. These habits make it describe your real data.

Paste several array items

Include two or three items that differ. Their shapes are merged, so genuinely optional keys are left out of required and mixed types become unions.

Use a populated sample

Keys that are only ever null or [] produce "type": "null" or "items": {}. A response with real values gives useful types.

Add business rules by hand

A sample cannot show limits. After generating, add enum, minimum, maxLength or pattern where your API enforces them, then test with the validator.

Frequently asked questions

What people usually ask about generating and validating JSON Schema.

What is a JSON Schema?

JSON Schema is a vocabulary, written in JSON, that describes the structure of a JSON document: which properties exist, what type each value has, which properties are required and what formats or ranges values must follow. It is used to validate API requests and responses, document payloads, generate forms and power editor autocompletion.

Is my JSON uploaded to a server?

No. Schema generation and validation run in your browser with JavaScript. Your JSON never leaves your device, so production payloads, tokens and customer data stay private.

Which JSON Schema draft should I use?

Use Draft-07 when you need the widest support across validators and editors. Use 2020-12 for new projects and for OpenAPI 3.1. Use Draft-04 only for older tooling such as Swagger 2.0 or validators that do not support newer drafts.

How does the generator decide which properties are required?

A property is required when it is present in every object observed at that position. For arrays of objects, all items are merged, so a key missing from any item is left optional. Turn off Mark keys as required to generate a schema without required lists.

How are null values handled?

A key that is only ever null is typed as "null". A key that is null in some samples and a string in others becomes a union type such as ["string", "null"]. Use a sample with populated values to get more useful types.

Why is a number typed as integer instead of number?

Whole numbers are typed as integer. If any value of the same key has a fractional part, the type is widened to number. In current browsers a value written as 10.0 is also recognised as a decimal. Turn off integer detection to always emit number.

Which string formats are detected?

date-time, date, uuid, email, uri and ipv4. A format is added only when every sampled value for that key matches it, and only when the selected draft defines the format: date needs Draft-07 or later and uuid needs 2019-09 or later.

Can I validate JSON against a schema?

Yes. The Validate JSON tab checks any JSON document against any schema and lists every error with its JSON Pointer path. It supports type, enum, const, numeric and string limits, pattern, format, items, prefixItems, contains, properties, patternProperties, additionalProperties, required, dependencies, allOf, anyOf, oneOf, not, if/then/else and local $ref. unevaluatedProperties, unevaluatedItems, $dynamicRef and remote $ref are not evaluated.

Can I export the schema as YAML or TypeScript?

Yes. Switch the output tab to YAML to get the same schema in YAML, for example for an OpenAPI file, or to TypeScript to get exported interfaces where optional properties are marked with ?.

Is the JSON Schema Generator free?

Yes. It is completely free, needs no sign-up, and has no limit on how many schemas you generate. Inputs up to 5 MB are supported.

Other browser-based utilities from SeeB4Coding.