Skip to main content

JSON Schema Generator

Infer a JSON Schema (Draft-07) from example JSON data — objects get properties and required keys, arrays get a merged (or anyOf) item schema, and numbers are typed as integer or number based on the sample. Runs entirely in your browser.

Input

Output

Generated JSON Schema
 
Was this helpful?

Guides

Paste an example JSON value — an object, an array, or a plain scalar — and get back a Draft-07 JSON Schema that describes its shape. It's the fastest way to bootstrap a schema for API validation, config files, or documentation without writing one keyword at a time by hand.

How it works

The generator walks your example value recursively:

  • Objects become "type": "object" with a properties entry for every key, plus a required array listing every key that was present.
  • Arrays become "type": "array" with an items schema inferred from the elements. If every element shares the same shape (an array of similarly-structured objects, for example), the items merge into one schema — properties are the union across all elements, and a key only stays in required if it appeared in every element.
  • Numbers are typed as "integer" when the sample is a whole number, or "number" when it has a decimal — and a merge that sees both an integer and a fractional sample widens to "number", since an integer-only schema would reject the fractional one.
  • Mixed-type arrays (e.g. [1, "two", true]) produce an items schema built from anyOf, one branch per distinct type seen, deduplicated so repeated identical shapes don't produce repeated branches.

About required

The required array reflects only the example you pasted — it is not a guarantee that a field is always present in every real document your API or config will ever see. If a key is sometimes optional, remove it from required in the generated schema (or paste an example that omits it, so the array-merge logic naturally treats it as optional).

Settings

  • Schema title (optional) — adds a title keyword to the root of the generated schema, useful for naming the type when you paste the result into documentation or a schema registry.

Privacy

Everything runs client-side in your browser — your example JSON is never sent to a server.

What if my JSON has more variety than one example shows?

Paste a richer example — an array with a few differently-shaped elements is often enough to get useful anyOf branches and a realistic required list, since the merge logic already handles heterogeneous array elements. To check a document against the schema you get back, use the JSON Schema Validator. If you need a TypeScript type or a Zod schema instead of JSON Schema, see the JSON to TypeScript Converter or the JSON to Zod Schema Generator.

jsonjson-schemaschemageneratordraft-07developercodegen

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.