Free JSON Schema Generator Online

Generate a JSON Schema from sample JSON for free. Choose draft 2020-12 or draft-07, detect required fields and formats like email, date and URI in your browser.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Create a JSON Schema From Sample Data (2020-12 vs Draft-07) →

About the JSON Schema Generator tool

JSON Schema describes what valid JSON looks like: which properties exist, their types, which ones are required and what formats strings must follow. Validators such as Ajv, OpenAPI specifications and form builders all consume it, but writing a schema from scratch for a large document is tedious. This generator drafts one from a sample.

Paste representative JSON and the tool infers a type for every value. Whole numbers become integer, decimals become number, and a property that holds several kinds of value gets a type list or an anyOf. Arrays of objects are merged, so properties that appear in every item are listed as required while those found in only some items stay optional. With format detection on, strings that are all emails, dates, date-times, times, URIs, UUIDs or IPv4 addresses receive a matching format keyword.

Choose draft 2020-12 or draft-07 for the $schema keyword, set a title, require every property if you prefer a strict contract, and add additionalProperties: false to reject unknown keys. Treat the output as a starting point: add descriptions, enums and minimum or maximum limits that only you know.

How to use JSON Schema Generator

  1. Paste a sample JSON document into “JSON sample” or click “Load sample”.
  2. Pick “Draft 2020-12” or “Draft-07” and type an optional “Title”.
  3. Toggle “Require every field”, “No additional properties” and “Detect formats” to taste.
  4. Copy the “JSON Schema” output or download it as a .schema.json file.

Features

Two drafts

Outputs the correct $schema URI for JSON Schema 2020-12 or draft-07.

Required fields inferred

Properties present in every array item are marked required; others stay optional.

Format detection

Recognises email, date, date-time, time, URI, UUID and IPv4 strings.

Integer vs number

Whole-number fields become integer; any decimal widens the field to number.

Strict mode switch

Optionally forbid unknown keys with additionalProperties: false.

When to use it

  • Bootstrap request and response schemas for an OpenAPI specification.
  • Validate incoming webhook payloads with Ajv in a Node.js service.
  • Document the structure of a JSON config file for other developers.
  • Create a schema for a VS Code settings file to get editor autocompletion.

Frequently asked questions

What is the difference between draft 2020-12 and draft-07?

Draft 2020-12 is the latest version and adds features such as prefixItems and $dynamicRef. Draft-07 is older but still widely supported. For the keywords this tool generates, the only difference is the $schema URI.

Why is a property not in the required list?

It was missing from at least one object in an array in your sample. Turn on “Require every field” if every property should be mandatory.

Does the schema validate my sample?

Yes. The schema is inferred from the sample, so the sample always satisfies it. Other documents may need adjustments, such as extra enum values or wider types.

Can it generate enums or min/max limits?

No. A single sample cannot tell which values are allowed, so enums, patterns and numeric limits should be added by hand.

Related tools