AI tools

Free AI JSON Schema generator

Paste sample JSON or describe the object. Get a clean JSON Schema with the right types, formats and required fields, plus notes on every guess it made.

How it works

  1. Paste a real JSON sample (one object or an array of them), or describe the fields in plain English.
  2. Pick the schema version and whether unknown fields should be rejected, add any rules such as allowed values or ranges, and click Generate schema.
  3. Copy the schema into your validator (Ajv, jsonschema, your API gateway) and read the notes: they list every guess, such as a nullable field or a pattern inferred from one example.

Examples

Sample results for the inputs shown, so you can see the format and quality before you try it.

Example 1: input

Sample JSON or a description: { "id": "7f3c2a9e-1b4d-4c8a-9e2f-3a5b6c7d8e9f", "email": "[email protected]", "name": "Ana Ruiz", "age": 34, "roles": [ "admin", "editor" ], "created_at": "2026-03-14T09:30:00Z", "address": { "city": "Madrid", "postal_code": "28013" }, "newsletter": true }

Schema version: Draft 2020-12

Strictness: Strict (reject unknown fields)

Example 1: output
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "User", "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "email": { "type": "string", "format": "email" }, "name": { "type": "string", "minLength": 1 }, "age": { "type": "integer", "minimum": 0 }, "roles": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "created_at": { "type": "string", "format": "date-time" }, "address": { "type": "object", "properties": { "city": { "type": "string" }, "postal_code": { "type": "string" } }, "required": [ "city", "postal_code" ], "additionalProperties": false }, "newsletter": { "type": "boolean" } }, "required": [ "id", "email", "name", "age", "roles", "created_at", "address", "newsletter" ], "additionalProperties": false } Notes: - Strict: every field in the sample is required and unknown fields are rejected, including inside address. - postal_code is a string, not a number, so codes with leading zeros survive. - roles allows any string. If only admin, editor and viewer are valid, add "enum": ["admin", "editor", "viewer"] to items. - Most validators treat format as a hint unless you turn format checking on (in Ajv: the ajv-formats plugin).
Example 2: input

Sample JSON or a description: Webhook payload for a new order: order_id (string), total in cents (integer, 0 or more), currency (USD, EUR or GBP), items (at least one; each has sku, quantity of 1 or more, unit_price_cents), optional coupon code, customer email.

Schema version: Draft-07

Strictness: Lenient (allow extra fields)

Example 2: output
{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "OrderCreatedWebhook", "type": "object", "properties": { "order_id": { "type": "string", "minLength": 1 }, "total_cents": { "type": "integer", "minimum": 0 }, "currency": { "type": "string", "enum": [ "USD", "EUR", "GBP" ] }, "items": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/lineItem" } }, "coupon_code": { "type": "string" }, "customer_email": { "type": "string", "format": "email" } }, "required": [ "order_id", "total_cents", "currency", "items", "customer_email" ], "definitions": { "lineItem": { "type": "object", "properties": { "sku": { "type": "string", "minLength": 1 }, "quantity": { "type": "integer", "minimum": 1 }, "unit_price_cents": { "type": "integer", "minimum": 0 } }, "required": [ "sku", "quantity", "unit_price_cents" ] } } } Notes: - Field names (total_cents, coupon_code, customer_email) are my choice because the description didn't give them. Rename them to match your payload. - Lenient: extra fields are allowed, so adding a field to the webhook later won't break consumers. - Draft-07 uses definitions for reusable parts; in 2019-09 and later it is $defs. - The schema can't check that total_cents equals the sum of the line items. Do that in code.
Example 3: input

Sample JSON or a description: { "sku": "TSHIRT-BLK-M", "title": "Black T-shirt", "price": 19.99, "discount_price": null, "tags": [ "cotton", "basics" ], "stock": { "warehouse_a": 12, "warehouse_b": 0 } }

Schema version: Draft 2020-12

Strictness: Lenient (allow extra fields)

Example 3: output
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Product", "type": "object", "properties": { "sku": { "type": "string", "pattern": "^[A-Z0-9]+(-[A-Z0-9]+)*$" }, "title": { "type": "string", "minLength": 1 }, "price": { "type": "number", "minimum": 0 }, "discount_price": { "type": [ "number", "null" ], "minimum": 0 }, "tags": { "type": "array", "items": { "type": "string" } }, "stock": { "type": "object", "additionalProperties": { "type": "integer", "minimum": 0 } } }, "required": [ "sku", "title", "price" ] } Notes: - discount_price was null in the sample, so it allows a number or null. I assumed it is a number when set. - stock looks like a map from warehouse name to count, so any key is allowed and each value must be a whole number of 0 or more. - The sku pattern (capitals, digits, hyphens) is a guess from one example. Remove it if your SKUs vary. - Lenient: only sku, title and price are required, and extra fields are allowed.

Tips for better results

  • Paste two or three real records instead of one. Fields that are null or missing in some records tell the generator what is optional.
  • Put business rules in the Extra rules box. A sample can't tell it that status only takes three values or that price is never negative.
  • Choose Strict for data you accept from outside (webhooks, public APIs) and Lenient for data you consume from others, so their new fields don't break you.
  • Turn on format checking in your validator if emails and dates matter. In Ajv that means adding ajv-formats; without it, format is not enforced.

FAQ

Is this JSON Schema generator free?

Yes. Enter your email once to use it (you'll also get Something Big, our free weekly AI newsletter, and you can unsubscribe anytime). There's no account and no credit card.

Which JSON Schema versions does it support?

Draft 2020-12, Draft 2019-09 and Draft-07. It sets the matching $schema URL and uses $defs or definitions to suit the version.

How does it decide which fields are required?

In Strict mode every field in your sample is required and unknown fields are rejected. In Lenient mode only the obvious essentials are required. Either way, the notes list the choices so you can adjust them.

Is the schema guaranteed to validate my data?

Run it against a few real records before you rely on it. The generator checks its own JSON and lists its assumptions, but it has not seen your full dataset.

More free AI tools

Related prompts

Prefer to use ChatGPT or Claude directly? These free prompts do similar jobs.

Get the best free AI tools and prompts every week

Something Big is a free AI newsletter read by 50,000+ professionals. One email a week with the AI tools and prompts that actually work, plus what changed in AI and what to do about it.