DataToolsLab
JSON Tools

JSON Schema Generator

Infer a JSON Schema automatically from sample JSON data.

Loading tool…

What is Schema Gen?

The JSON Schema Generator takes a sample JSON document (or an array of samples) and produces a standards-compliant JSON Schema document describing its structure, types, required fields, and format constraints — saving hours of writing schema boilerplate by hand.

How it works

We recursively walk the parsed JSON and map every value to its corresponding JSON Schema type, format, and sub-schema. When you paste an array of objects, we merge across all samples to detect optional fields, union types, and low-cardinality enums.

  1. Paste JSON data. Drop a .json file or paste a JSON object or array. For best results with optional-field detection, paste an array of sample objects.
  2. Choose draft version. Select draft-07, 2019-09, or 2020-12. The $schema field is set automatically.
  3. Copy or download. Copy the generated schema to clipboard or download as schema.json.

Examples

Single user object

{ "name": "Alice", "age": 30 } generates a schema with type "object", two string/number properties, and both marked required.

Array of samples (enum detection)

An array like [{role:"admin"},{role:"editor"}] generates an enum constraint: { "type": "string", "enum": ["admin", "editor"] }.

Common mistakes

Single sample means all keys required

With a single object, every key is treated as required because we can't tell which fields are optional. Paste an array of objects for proper optional detection.

Format detection is conservative

We only infer well-known formats (email, date, date-time, uri, ipv4, ipv6, uuid) when the value unambiguously matches. Custom formats are not detected.

Alternatives

JSON Schema Validator

Validate a JSON document against a schema once you have one.

JSON Validator

If you only need syntax-level validity, the JSON Validator is lighter.

Frequently asked questions

Does it support all JSON Schema drafts?

Yes — you can choose draft-07, 2019-09, or 2020-12. The output's $schema field matches your selection.

Can it detect enums?

Yes. When an array of samples contains a string field with 2–8 unique values, the generator emits an enum constraint.

Online