DevKit
Generator

JSON to JSON Schema

Infer a Draft-07 JSON Schema from a sample JSON document.

Last updated: August 2026

Infers a Draft-07 JSON Schema from a sample. All keys are marked required — adjust as needed.

Share:

Was this tool helpful?

Inferring a schema from data

A JSON Schema describes the shape data is allowed to take: which keys exist, their types, which are required. Writing one from scratch is slow, so inferring a draft from a sample document gives you a starting point. This tool walks a sample and produces a Draft-07 schema you then tighten by hand.

Example

Sample input:

{ "id": 7, "name": "Ada" }

Inferred schema:

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

Inference is a draft, not an answer

One sample cannot reveal which fields are truly optional. The tool marks every key it sees as required, which is almost always too strict for real data. It also cannot know your intended constraints: string length, number ranges, enums, or formats like email and date-time. Add those yourself. Treat the output as scaffolding, then prune the required array and add validation keywords.

Arrays with mixed items

For an array, inference looks at the elements and generalizes. A list of objects with slightly different keys may produce a loose items schema that accepts more than you intend. Feed it a sample that covers the real variety, or merge several samples before inferring.

FAQ

Why is everything required? The tool only sees what is present, so it assumes presence is mandatory. Remove keys that can be omitted from the required list.

Can I validate against the result? Yes, feed the schema and some data to the JSON Schema validator to confirm it accepts and rejects the right documents.