Hunt
Skip to content

JSON to JSON Schema

Paste a sample of your JSON, such as an API response or a configuration file, to get a JSON Schema that describes it: types, integers, string formats such as email and date-time, required and optional fields, and the items of arrays. Use it as a starting point for API validation, OpenAPI documents or form generators. Nothing is uploaded.

Runs in your browser

JSON

Paste JSON or press Sample

JSON Schema

The schema will appear here

How the schema is inferred

  • Types: each value's JSON type, with integer for numbers that are always whole.
  • Formats: strings get format: email, uri, uuid, date or date-time when every sample value matches.
  • Arrays of objects are merged: a property missing from some items isn't required, and a property with different types gets a list of types or anyOf.
  • Required: properties present in every sample are listed in required.
  • A property that is null in every sample is typed null; give it its real type by hand.

How to use the JSON to JSON Schema

  1. Paste sample JSON, or press Sample. For an array, include several items so optional fields are detected.
  2. Choose the draft, and whether to require fields and forbid extra properties.
  3. Copy or download the schema, and refine it: add descriptions, minimums or enums.

Examples

Formats and integers

Input
{"id":"7f3c9a8e-2b1d-4e5f-9a6b-1c2d3e4f5a6b","email":"ada@example.com","age":36,"createdAt":"2026-11-10T09:41:22Z","tags":["math","engines"]}
Output
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"email": {
"type": "string",
"format": "email"
},
"age": {
"type": "integer"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["id", "email", "age", "createdAt", "tags"]
}

Array items merged

Input
[{"sku":"BK-12","qty":2,"note":"gift"},{"sku":"PN-03","qty":1.5,"note":null}]
Output
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"qty": {
"type": "number"
},
"note": {
"type": ["string", "null"]
}
},
"required": ["sku", "qty", "note"]
}
}

qty is number because one item has 1.5, and note is a string in one item and null in the other.

Draft 7, no extra properties

Input
{"name":"web","port":8080}
Output
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"port": {
"type": "integer"
}
},
"required": ["name", "port"],
"additionalProperties": false
}

2020-12 or draft 7?

Draft 2020-12 is the current version of JSON Schema, used by OpenAPI 3.1. Draft 7 is older but still the most widely supported, for example by many form builders and editors. The generated keywords mean the same in both; only $schema differs.

Options

Draft
2020-12 (the default, as used by OpenAPI 3.1) or draft 7.
Title
An optional title for the root schema.
Required fields
List properties present in every sample in required (on by default).
No extra properties
Add additionalProperties: false to every object, so unknown properties are rejected.
Detect formats
Add format for emails, URLs, UUIDs, dates and date-times (on by default).

Limitations

  • A schema inferred from samples describes only what the samples show: add minimums, maximums, patterns and enums yourself.
  • Large numbers and very long arrays are fine, but every item of an array is assumed to have the same kind of structure.

Frequently asked questions

Is my JSON uploaded?

No. The schema is generated in your browser; nothing you paste is sent anywhere.

Does the sample pass the generated schema?

Yes, always: the schema is built so that the JSON it was generated from is valid. Check it, or other documents, with the JSON Schema Validator.

Can I generate TypeScript types or Zod schemas instead?

Yes: use JSON to TypeScript or JSON to Zod Schema, which use the same inference.