Skip to content
epitometool

JSON Schema generator

JSON & data

Infer a JSON Schema (draft 2020-12) from a sample JSON document — types, required keys, and nested structure, all client-side.

Updated

Sample JSON

JSON Schema (draft 2020-12)

  • EnterCopy schema
  • KClear input

Quick start

How to use the JSON Schema generator

Paste a JSON sample, get an inferred schema — nothing leaves your browser.

  1. Step 1
    Paste a sample

    Drop a representative JSON document into the left pane.

  2. Step 2
    Read the schema

    A draft 2020-12 schema with types, properties, and required keys appears on the right.

  3. Step 3
    Copy and refine

    Copy with the button or ⌘/Ctrl+Enter, then add formats, enums, and ranges by hand.

In-depth guide

Generating a JSON Schema from a sample document

Writing a JSON Schema by hand is tedious; inferring a first draft from a real payload is far faster. This tool reads a sample JSON document and produces a draft 2020-12 schema — types, object properties, required keys, and merged array item shapes — entirely in your browser. Use it as a scaffold you then refine with formats, enums, and constraints.

What the generator produces

Given a sample value the tool walks its structure and emits a schema fragment for each node: type for scalars, a properties map plus required for objects, and an items schema for arrays. Whole numbers are typed as integer, fractional ones as number. The root is wrapped with the $schema keyword pointing at draft 2020-12.

When a generated schema helps

  • Documenting an API response you do not control — capture a real payload and infer its shape.
  • Bootstrapping validation for a config file or message format before tightening rules.
  • Onboarding — turning an example into a readable contract for teammates.

It saves the structural typing; you add the semantics (formats, ranges, which fields are truly optional).

Step by step

  1. Paste a representative JSON document into the left pane — the more complete the sample, the better the schema.
  2. For optional fields, paste an array of objects, some with and some without the field; the merge step will keep it out of required.
  3. Read the inferred schema on the right.
  4. Copy it with the button or ⌘/Ctrl+Enter and refine by hand.

Common pitfalls

The output is a starting point, not a finished contract. Always review it before validating production data.

  • Everything looks required. A single sample makes every key appear mandatory — prune the required array or supply varied samples.
  • No formats or enums. Inference cannot tell an email from any other string, or a fixed set of values from a free one. Add format, enum, and range keywords yourself.
  • Empty arrays give an open items schema. With no elements to inspect, items defaults to {} (anything). Provide at least one element to constrain it.

Privacy and how it runs

Parsing and inference run with the browser's native JSON parser inside the tab. No document is uploaded, logged, or stored, and there is no eval anywhere in the code path — so even malformed or sensitive JSON stays on your machine. Close the tab and nothing persists.

When to use it vs alternatives

Use this tool for quick inspection, cleanup, conversion, and copy-paste debugging. Use your IDE formatter, schema tests, or CI checks when the same rule needs to be enforced across a repository.

Frequently asked questions

Does this tool send my JSON anywhere?

No. Your JSON is parsed with the browser's built-in JSON.parse and the schema is inferred in memory. Nothing is uploaded, so you can generate schemas from sensitive payloads safely — confirm in DevTools → Network.

Which JSON Schema draft does it produce?

Draft 2020-12, the current version, identified by the $schema keyword pointing at json-schema.org/draft/2020-12/schema. The structural keywords used (type, properties, required, items, anyOf) are compatible with most older drafts too.

How are types inferred?

From the sample values: strings become "string", booleans "boolean", null "null", and numbers become "integer" when whole and "number" otherwise. Objects produce a properties map with every key marked required, and arrays produce an items schema merged across all elements.

What happens with arrays of mixed shapes?

The tool merges the schemas of all array elements. Objects are merged by unioning their properties and keeping only keys present in every element as required. When element types genuinely conflict, it emits an anyOf listing each shape, which you can then refine by hand.

Is the generated schema production-ready?

Treat it as a strong first draft. Inference cannot know your intent — it will mark every observed key as required and cannot guess formats (email, date-time), enums, or value ranges. Review and tighten the output before using it to validate real traffic.

Why are all properties marked required?

The tool only sees one sample, so every key in that sample looks mandatory. If a field is optional, remove it from the required array — or paste a sample array containing objects both with and without the field, and the merge step will drop it from required automatically.

Keep exploring

More tools you'll like

Hand-picked utilities that pair well with the one you're on — all free, client-side, and zero-signup.