JSON Schema Builder
A visual JSON Schema builder and generator for LLM structured outputs. Add fields or infer them from sample JSON, then copy the schema for OpenAI response_format or Claude tool use.
Build Structured Output Schemas Without Hand-Writing JSON
Structured outputs make an LLM reply with JSON that matches a schema you define, so your code can parse the answer instead of scraping free text. Writing those schemas by hand is fiddly: every object needs its required list, strict modes forbid extra properties, and each API wraps the schema differently.
This JSON Schema builder lets you add fields, pick types, mark them required and nest objects and arrays. The schema updates live, together with ready-to-paste snippets for OpenAI (Chat Completions and Responses API) and Anthropic (tool use and structured outputs). You can also paste sample JSON and generate a schema from it.
How to build a JSON Schema
- Name the schema with letters, numbers, underscores or hyphens, for example
contact_info, and add a short description. - Add fields. Give each one a name, a type and a description. Descriptions are sent to the model, so write them as instructions.
- Nest data. Choose
objectto add child fields, orarrayand pick the item type. Arrays of objects get their own child fields. - Copy the output from the JSON Schema, OpenAI or Anthropic tab.
Already have example data? Paste it into Generate from sample JSON. Keys that are missing or null in some array items are marked optional.
Field types and the JSON Schema they produce
| Builder type | JSON Schema | Example value |
|---|---|---|
| string | {"type": "string"} | "Berlin" |
| number | {"type": "number"} | 59.9 |
| integer | {"type": "integer"} | 2 |
| boolean | {"type": "boolean"} | true |
| enum | {"type": "string", "enum": [...]} | "senior" |
| array | {"type": "array", "items": {...}} | ["SQL", "Python"] |
| object | {"type": "object", "properties": {...}} | {"city": "Pune"} |
Every object gets "additionalProperties": false, which both OpenAI strict mode and Anthropic structured outputs require.
Strict mode and optional fields
With OpenAI structured outputs in strict mode, every property must appear in required. To keep a field optional, the builder adds "null" to its type, for example "type": ["string", "null"], so the model returns null when it has no value. The plain JSON Schema and the Anthropic snippets keep the normal required list, and the Anthropic tool gets "strict": true when strict mode is on.
Which Claude option should you use? Choose output_config.format when you simply want the reply itself as JSON, for example to extract fields from a document. Choose tool use when the JSON is the input for an action in your code, or when Claude should decide between several tools. Both accept the same schema, so you can switch later without rewriting it.
Where to paste the snippets
| API | Parameter | Result |
|---|---|---|
| OpenAI Chat Completions | response_format with type: "json_schema" | The message content is JSON matching the schema |
| OpenAI Responses API | text.format | The output text is JSON matching the schema |
| Anthropic tool use | tools[].input_schema | Claude calls the tool with arguments matching the schema |
| Anthropic structured outputs | output_config.format | Claude’s reply text is JSON matching the schema |
Tips for reliable structured outputs
- Describe every field. “Price in euros, without currency symbol” works far better than a bare
price. - Prefer enums for categories so you never get “Senior”, “senior” and “Sr.” in the same column.
- Keep it flat. Deep nesting and very large schemas are harder for models and may hit provider limits.
- Validate anyway. Check the parsed result in code, and test long schemas against the Context Window Checker because the schema counts as input tokens. To check many saved results at once, use the JSONL Validator.
Frequently Asked Questions
Common questions about JSON Schema for LLM structured outputs.
A JSON Schema is a JSON document that describes the shape of other JSON: which properties exist, their types, which are required and which values are allowed. LLM APIs use it to constrain model output.
Yes. Paste a JSON object or an array of objects into Generate from sample JSON. The builder infers types, merges keys across array items and marks keys that are missing or null as optional.
In OpenAI strict mode the model is guaranteed to follow the schema exactly, but all properties must be required and additionalProperties must be false. On Claude, strict tool use guarantees that tool arguments validate against the schema.
Keep it in the required list and allow null as a type, for example ["string", "null"]. The builder does this automatically for fields you leave unticked.
Yes. The schema and its descriptions are sent with the request and billed as input tokens. Count them with the LLM Token Counter.
Providers support a subset. Anthropic, for example, does not support recursive schemas or numeric and string length constraints in structured outputs. The builder only produces widely supported keywords: type, properties, required, items, enum and additionalProperties.
Yes. The plain JSON Schema tab is standard draft 2020-12 and works with validators such as Ajv and with most frameworks that accept JSON Schema for tool or function definitions.
No. The builder and the sample JSON inference run entirely in your browser.