AI & LLM Developer Tools

Structured Output Schema Builder

Design the JSON Schema a model must answer in, field by field, validate example outputs against it, and export it in the shape each provider's structured-output feature expects.

  • JSON Schema
  • Provider-specific request snippets
  • Validation of the example
Runs in your browser

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics.

Output schema workspace

1 Fields

Examples:
Define the schema with

One field per line: name: string "description". Add ? after a name for optional, after a type for nullable; [] for arrays; enum(a|b); {min=0 max=10 pattern=^A}; indent two spaces under object or object[]. Formats: date, date-time, time, email, uri, uuid.

2 Example model output (optional)

3 Schema and request snippets

Describe your fields or load an example.

What the Structured Output Schema Builder does

This builder produces the JSON Schema a model must answer in, from one short line per field, and turns it into ready-to-paste request snippets for OpenAI Structured Outputs (Responses and Chat Completions), Anthropic structured outputs and Gemini's responseJsonSchema. It checks the schema against each provider's documented restrictions and validates an example output against it.

The three providers accept overlapping but different subsets of JSON Schema. OpenAI's strict mode wants every property listed as required and additionalProperties: false everywhere; Anthropic rejects numeric bounds, string lengths and regex patterns; Gemini documents only a handful of keywords. A schema that works on one can fail with a 400 error - or be quietly loosened - on another, so the differences are listed per provider rather than hidden.

How to use it

  1. Name the schema, then write one line per field: total: number "Grand total including tax". Add ? after the name for an optional field, ? after the type for a nullable one, [] for a list, enum(a|b|c) for fixed values and {min=0 max=100} for bounds. Indent two spaces under an object or object[] field to nest.
  2. Or switch to JSON Schema and paste a schema you already have.
  3. Paste a real or expected model output in the example box to see whether it would pass.
  4. Press Build and check. Fix anything marked Problem for the provider you use, then copy the snippet from its tab or download the schema.

Reading the results

Problems are restrictions the provider documents as unsupported or required - the request is likely to be rejected. Warnings are keywords the provider does not document, which may be ignored rather than enforced; if they matter, check them in your own code after the response arrives.

The OpenAI tabs show the strict variant: optional fields are made required with null added to their type, because strict mode requires every property in required. Your code should treat null as absent.

Example validation covers types, required and unexpected properties, enums, lengths, bounds, item counts, patterns and common formats. Date formats are checked for shape, not calendar validity.

Worked example: an invoice extraction schema

The invoice example has eleven lines: supplier, invoice number, issue date, an optional due date, a currency enum of EUR, GBP, USD and INR, a list of at least one line item (description, quantity with a minimum of 0, unit price), a total and a nullable VAT number.

It builds cleanly. The OpenAI check notes that due_date is optional, so the strict export lists it as required with type ["string", "null"]. Anthropic flags one problem: minimum on lines[].quantity is not supported, so remove it for Claude and check the quantity in code. Gemini raises nothing: date is one of its documented formats and minimum is supported for numbers.

The example output - Northwind Ltd, INV-2291, one line of 10 x 124, total 1,240, VAT number null - passes validation. The ticket-triage example shows a failing case: six tags against maxItems=5.

Designing a schema a model fills in well

Descriptions matter as much as types: the model reads them. Say what a field means, its unit and what to do when the source does not contain it - "null when the invoice shows none" is clearer than an optional field the model must decide to omit.

Prefer enums over free text wherever the set of answers is known, keep nesting shallow, and put a reasoning or evidence field before the fields that depend on it if you want the model to think first. Structured outputs guarantee the shape, not the truth of the values, so validate business rules - totals that add up, dates in order - after the response.

Limitations: what the result does not prove

  • Provider rules change. The checks reflect each provider's structured-output documentation as reviewed on the date above; re-test against the live API before relying on an edge case.
  • The field-line syntax covers common schemas. anyOf, $ref, const and recursive definitions need the JSON Schema mode, and the validator implements only the subset this builder emits plus anyOf.
  • A schema-valid answer can still be wrong. Structured outputs constrain format, not facts.
  • Model names in the snippets are placeholders; use the model you actually call.

Privacy: where your data goes

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics. Session recording and tag-manager scripts are switched off on this page.

Standards and sources

Frequently asked questions

Why does OpenAI require every field to be required?

In strict mode OpenAI constrains generation to the schema, and its documentation requires all properties to appear in required with additionalProperties: false. To make a field optional you allow null instead - the builder does that conversion for the OpenAI tabs and leaves the other providers' schemas as you wrote them.

Which JSON Schema keywords does Claude's structured output not support?

Anthropic's documentation lists numeric constraints (minimum, maximum, multipleOf), string constraints (minLength, maxLength, pattern), maxItems, minItems other than 0 or 1, recursive schemas and additionalProperties other than false. The builder marks each as a problem so you can move that check into your code.

How do I get JSON output from Gemini with a schema?

Set responseMimeType to application/json and pass the schema in responseJsonSchema inside generationConfig of a generateContent request. The Gemini tab shows that shape. Google documents a smaller keyword set than JSON Schema allows, so warnings list anything outside it.

Is structured output the same as JSON mode?

No. JSON mode only promises syntactically valid JSON; structured outputs constrain the answer to your schema - the right keys, types and enum values. Use structured outputs when code consumes the result, and keep validating it anyway.

Should I use structured outputs or function calling?

Use structured outputs when you want the model's reply itself in a fixed shape, such as an extraction. Use function calling when the model should decide whether and how to call your code, with arguments in a schema. The Function Calling Schema Builder handles the second case.

What does the example validation prove?

That one sample matches the schema you built - useful for catching a mismatch between what you expect and what you declared. It does not show that a provider will enforce every keyword; warnings mark the ones it may ignore.

Last reviewed by the A2Z.Tools team against the sources listed above.

Rate this tool

Was this tool useful? Your feedback helps us improve it.

No ratings yet — be the first to rate this tool.
Your rating (required)
0 / 2000

Please do not include passwords, payment details or other sensitive information.

Your feedback is sent privately to the A2Z.Tools team and will not be posted publicly.