JSON Schema Generator

Infer a JSON Schema (draft-07) from a sample document.

Open tool

Overview

The JSON Schema generator examines a sample JSON document and produces a draft-07 schema that describes it. Field types, required keys, array element types, and basic constraints are inferred so you have a working schema you can refine.

It's the fastest way to bootstrap validation for an API contract, generate a typed model from sample data, or document the shape of an existing payload. Backend developers, API designers, and data engineers reach for a json schema inference tool to skip the tedium of writing schemas from scratch.

How it works

The generator walks the input recursively. Objects become {"type":"object","properties":{...}} with each key's type inferred from its value. Required keys are taken from the keys present in the sample — every property in the sample is marked required because the sample is the only evidence available. Arrays become {"type":"array","items":...} with items set to the common shape across elements.

For strings, the generator detects common formats: date-time, date, email, uri, uuid. Numbers split into integer and number. Nulls produce {"type":"null"} standalone or are added to a union when mixed with other types in an array.

Examples

Sample:
{ "id": 1, "name": "Alice", "active": true, "joined": "2024-01-15" }

Schema:
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id":     { "type": "integer" },
    "name":   { "type": "string" },
    "active": { "type": "boolean" },
    "joined": { "type": "string", "format": "date" }
  },
  "required": ["id","name","active","joined"]
}

FAQ

Should I trust the required list?

Treat it as a starting point. The generator marks every observed property required because it only sees one sample; review and relax it for optional fields. Pass several samples through the tool and merge the schemas if you need a more accurate signal.

Does it produce draft 2020-12?

Output is draft-07 by default since it's the most widely supported. Draft 2020-12 is selectable as an option and changes definitions to $defs plus tuple items semantics.

How are nested arrays handled?

Heterogeneous arrays produce a union: {"items":{"oneOf":[{...},{...}]}}. Homogeneous arrays produce a single items schema. The generator picks the most specific representation that fits every element.

Try JSON Schema Generator

An unhandled error has occurred. Reload ×