og.cc.cd / json-schema-generator

JSON Schema Generator for Structured Outputs

Paste a sample JSON response and get a JSON Schema that works with OpenAI Structured Outputs and strict function calling — or a plain draft 2020-12 schema for validators.

TL;DR: Paste sample JSON to get a schema that OpenAI Structured Outputs strict mode accepts (additionalProperties: false, every key required, optional fields as nullable) or a plain draft 2020-12 schema.

Updated · Official sources: OpenAI Structured Outputs · JSON Schema specification

JSON Schema


How to use the JSON Schema generator

  1. Paste one realistic example of the JSON you want the model to return. Use real-looking values: integers stay integer, decimals become number, null marks a field as nullable.
  2. Choose OpenAI strict for Structured Outputs or strict: true function calling, and pick the wrapper that matches your API call. Choose draft 2020-12 for validators such as Ajv.
  3. Add description fields and enums by hand for important keys — the model reads them — then copy the result into your code.

Related guides: OpenAI Structured Outputs and JSON Schema · Estimate LLM API costs · How tokens work

FAQ

What does OpenAI strict mode require?

With strict: true, every object must set additionalProperties: false, every property must be listed in required, and the root must be an object (not anyOf). Optional fields are expressed as a union with null, for example "type": ["string", "null"]. Keywords such as allOf, not and if/then/else are not supported.

What are the size limits?

OpenAI’s Structured Outputs docs allow up to 5,000 object properties in total and up to 10 levels of nesting, plus limits on total string length and enum size. The generator warns when your schema exceeds the property or depth limit.

How are optional and missing keys handled?

Paste several objects in an array and tick “treat a top-level array as multiple samples”. In strict mode a key that is missing from some samples stays required but becomes nullable; in draft 2020-12 mode it is simply left out of required.

Can I use the schema with other models?

The draft 2020-12 output is a standard JSON Schema for validators and most tools. The strict output follows OpenAI’s subset; other vendors’ structured-output features support different subsets, so check their docs before reusing it.

Is my JSON uploaded?

No. Parsing and schema generation run entirely in your browser.