Paste sample JSON and get a JSON Schema that knows which keys are optional, which values can be null and which strings are emails, dates or URLs. Export it as TypeScript, Zod or a strict schema for OpenAI and Claude, then test documents against it. It runs in your browser.
Free JSON Schema generator. Paste example JSON or a .json file and get a JSON Schema (Draft-04 to 2020-12), TypeScript interfaces, a Zod schema, an OpenAI strict response_format or an Anthropic tool definition. Array items are merged to infer optional and nullable keys. A Validate tab checks other documents against the schema. Runs in the browser.
Your schema shows up here
Paste sample JSON and pick an output: JSON Schema, TypeScript, Zod or an AI structured output.
Was this tool helpful?
These two records go in. The company key only appears in the first, and trial_ends is null in the first and a date in the second. Every output says the same thing in its own format.
In
[ { "id": 1, "email": "maya@example.com", "plan": "pro", "company": "Northwind", "trial_ends": null }, { "id": 2, "email": "luis@example.com", "plan": "free", "trial_ends": "2026-10-01" } ]
Out
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "email": { "type": "string", "format": "email" }, "plan": { "type": "string" }, "company": { "type": "string" }, "trial_ends": { "type": [ "string", "null" ], "format": "date" } }, "required": [ "id", "email", "plan", "trial_ends" ] } }
JSON Schema. Validate API payloads, config files and form data with Ajv or any validator.
export type Accounts = Account[]; export interface Account { id: number; /** Format: email */ email: string; plan: string; company?: string; /** Format: date */ trial_ends: string | null; }
TypeScript. Type the response in your frontend or SDK.
import { z } from "zod"; export const Account = z.object({ id: z.number().int(), email: z.email(), plan: z.string(), company: z.string().optional(), trial_ends: z.iso.date().nullable(), }); export const Accounts = z.array(Account); export type Accounts = z.infer<typeof Accounts>;
Zod. Parse and validate at runtime, and get the type from z.infer.
{ "type": "json_schema", "json_schema": { "name": "accounts", "strict": true, "schema": { "type": "object", "properties": { "items": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "email": { "type": "string", "format": "email" }, "plan": { "type": "string" }, "company": { "type": [ "string", "null" ] }, "trial_ends": { "type": [ "string", "null" ], "format": "date" } }, "required": [ "id", "email", "plan", "company", "trial_ends" ], "additionalProperties": false } } }, "required": [ "items" ], "additionalProperties": false } } }
OpenAI strict. Make the model return exactly this shape. The missing key became nullable.
An array of real records from your API gives the best schema. Keys that come and go become optional, and values that are sometimes null become nullable.
Draft-07 fits most tools. Switch on No extra keys to add additionalProperties: false, and Enums to turn repeated values like status codes into a fixed list.
Take the JSON Schema, TypeScript, Zod or AI output. Paste another document into Validate to see exactly which paths fail.
OpenAI strict mode only accepts a subset of JSON Schema. The same samples produce a slightly different schema there, and the AI output tab handles the changes for you.
| JSON Schema tab | OpenAI strict | |
|---|---|---|
| Key in every sample | Listed in required | Listed in required |
| Key missing from some samples | Left out of required | Required, and null is allowed |
| Value that is sometimes null | type: ["string", "null"] | type: ["string", "null"] |
| Extra keys | Allowed unless you turn on No extra keys | additionalProperties: false on every object |
| Email, date and uuid strings | format, if your draft defines it | format, from OpenAI's supported list |
| Top-level array | type: array | Wrapped in an object under items |
See which models handle agents and tool calls best, and what a schema-heavy prompt costs.
Paste a sample JSON document or drop a .json file into the generator. The schema appears as you type, with types, required keys, nested objects and arrays filled in. Pick a draft, then copy the schema or download it as a .schema.json file. For better results, paste an array with several samples so the generator can compare them.
Draft-07 unless a tool asks for something else. It's widely supported by validators, editors and API tools. Pick 2020-12 for new projects on a current validator such as Ajv's 2020 build. The draft changes the $schema line and which format values are written: date needs Draft-07 or later, and uuid needs 2019-09 or later.
A key is required when it appears in every sample at that position. The generator merges all items in an array, so a key missing from one item becomes optional, a value that is sometimes null gets a null type, and whole numbers stay integer unless any sample has a decimal. Turn off Required keys to leave the required list out.
Yes. The TypeScript tab writes an interface for each nested object, with optional keys marked by a question mark and nullable values typed as a union with null. The Zod tab writes the same shape in Zod 4 syntax, using z.email(), z.url() and z.iso.datetime() where it detected those formats, plus a z.infer type.
Open the AI output tab and choose OpenAI. You get a response_format object with strict set to true. Strict mode needs every key listed in required and additionalProperties set to false on every object, so keys missing from some samples become nullable. A top-level array is wrapped in an object, because the root must be an object.
Yes. Choose Anthropic in the AI output tab to get a tool definition with a name, a description to fill in, strict set to true and an input_schema. Every object gets additionalProperties set to false, which strict tool use needs, and optional keys stay out of required. Paste it into the tools array of a Messages API request.
Open the Validate tab and paste another document. It checks it against the schema as you type and lists each problem with its path, such as $.users[0].email, and what's wrong. It covers the keywords this generator writes: type, required, properties, additionalProperties, items, enum, format and anyOf. For other schemas, use a full validator like Ajv.
No. Parsing, schema generation, the TypeScript and Zod output and validation all run in your browser. Nothing is sent to a server and there's no signup, so it's fine to use with API responses that contain customer data. Clearing the page or closing the tab removes the data.
Everything from model picks to CSV converters, with no account needed.