Developer & API

JSON Schema Generator: Instantly Create Valid JSON Schemas

Turn a sample payload into a validation schema.

Paste a JSON document and this generator infers a JSON Schema for it — types, nested objects, arrays, required fields and enums — using the current Draft 2020-12 dialect. Use the output as a starting point, then tighten it by hand: an inferred schema describes the sample you gave it, and a good schema describes every document you are willing to accept.

JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "email": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "active": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "email",
    "tags",
    "active"
  ]
}

JSON, YAML & Data Wrangling Cheat Sheet

25 jq recipes, JSONPath syntax, reusable JSON Schema patterns and the YAML gotchas that break pipelines.

One email, no spam, unsubscribe any time.

About this tool

The generator walks your sample document, infers a type for every value, merges array item shapes, and marks observed keys as required — a solid starting point you can then tighten by hand.

Why generate a schema

Schemas let you validate requests and responses in CI, generate typed clients and document your API without maintaining prose.

Refining the output

Add formats such as date-time or email, constrain enums, and relax required lists for optional fields the sample happened to include.

From an inferred schema to a schema you can rely on

Inference gets you the shape for free, but four things always need a human. Required: the generator marks every key present in your sample as required, which is usually too strict for optional fields. Formats: a string that is really a date, email, URI or UUID should carry a format keyword. Constraints: add minLength, maximum, pattern and enum so bad values are rejected rather than merely typed correctly. And additionalProperties: set it to false on closed objects, otherwise a typo'd key silently passes validation — the single most common cause of a schema that validates everything and catches nothing.

Which draft to target

Draft 2020-12 is the current specification and the right default for new work. Draft-07 remains the most widely supported by older tooling and is a safe choice if your validator or code generator has not caught up. The visible differences matter: 2020-12 replaced the array form of items with prefixItems for tuples, introduced $dynamicRef, and reworked $recursiveRef. Always declare the dialect explicitly with $schema so a validator never has to guess.

Validating in CI, not in code review

A schema earns its keep the moment it runs automatically. Validate API responses against the schema in your integration tests, validate request bodies at the edge of your service, and validate configuration files and event payloads in CI. Ajv is the standard JavaScript validator and is fast enough to run per request; jsonschema covers Python, and everything-json-schema covers most other languages. Pair the schema with a handful of deliberately invalid fixtures so you can prove the schema actually rejects things.

Reuse with $defs and $ref

Define shared shapes — an address, a money amount, a pagination envelope — once under $defs and reference them with $ref: '#/$defs/Address'. For schemas shared across services, publish them at stable URLs and reference them absolutely, versioning by path rather than mutating a schema in place. Mutating a published schema breaks consumers exactly as badly as changing an API response, and it does so silently.

Schemas, OpenAPI and TypeScript types

JSON Schema is the substrate under OpenAPI 3.1, so a schema you generate here drops directly into an OpenAPI components/schemas block. From there, json-schema-to-typescript produces TypeScript interfaces, and equivalent generators exist for Go, Java, Python and Rust. Generating types from the schema — rather than writing types and a schema separately — keeps runtime validation and compile-time types from drifting apart, which is the failure mode every hand-maintained pair eventually reaches.

Common JSON Schema keywords by type

Applies toKeywordPurpose
anytype, enum, const, $refDeclare the type or fix the value
stringminLength, maxLength, pattern, formatLength, regex and semantic format
numberminimum, maximum, exclusiveMinimum, multipleOfNumeric bounds and steps
objectproperties, required, additionalProperties, patternPropertiesShape and strictness
arrayitems, prefixItems, minItems, maxItems, uniqueItemsElement type and cardinality
compositionallOf, anyOf, oneOf, not, if/then/elseCombine and branch between schemas

Useful string formats

formatMatches
date-time2026-09-05T12:40:00Z (RFC 3339)
date2026-09-05
emailuser@example.com
urihttps://example.com/path
uuid3f2504e0-4f89-11d3-9a0c-0305e82c3301
ipv4 / ipv6192.168.0.1 / ::1
hostnameapi.example.com

How to use JSON Schema Generator

  1. 1

    Open JSON Schema Generator

    Everything runs on this page — there is nothing to install and no account required to use the free features.

  2. 2

    Add your input

    Paste or enter your values in the panel above. The tool updates as you type, so you can iterate quickly.

  3. 3

    Review the output

    Check the result, copy it with one click, and adjust the options until it matches what your system expects.

  4. 4

    Take it further

    Use the developer & api tips below to make the result production-ready, then unlock the gated extras via the form above.

Best practices

  • Work from a real payload, not a hand-typed sample — encoding bugs hide in whitespace and Unicode.
  • Keep the transformation reproducible: script it in CI once you have confirmed the output here.
  • Never paste live credentials, customer records or production tokens into any web tool you have not audited.
  • Version the inputs and outputs you rely on so a teammate can reproduce the same result later.

JSON Schema Generator — Why it matters

Small integration details — an encoding, a claim, a header — are where most API bugs actually live, and they are expensive to find in production logs.

Getting them right in seconds keeps debugging sessions short and prevents malformed data from reaching downstream systems.

Related free & paid tools

Tool nameTypeKey featuresLink
quicktypeFreeGenerates types and schemas from sample JSONVisit
AjvFreeFastest JSON Schema validator for Node and browsersVisit
ZodFreeTypeScript-first schema validation with inferenceVisit
StoplightOfferFreemiumAPI design platform with schema modelling and lintingVisit

Some links marked Offer are partner links. They cost you nothing extra and help keep these tools free.

Related tools

Frequently asked questions