Tools

JSON to JSON Schema generator

Infer a JSON Schema from a sample, with an OpenAI strict-mode option for structured outputs and function calling.

Runs in your browserAI developer tools13.9K
Free

Input

0 B

Result

The result will appear here.

Structured outputs and function calling both want a JSON Schema, and writing one by hand for a nested API response is slow and easy to get subtly wrong. Paste a real sample — ideally an array with several records — and get a schema back. The inference merges every example it sees, so a key missing from one record becomes optional, a value that is sometimes null becomes nullable, and a field that is always an ISO timestamp gets format date-time. Strict mode rewrites the result into the subset OpenAI's Structured Outputs accepts.

How it works

  • Inference is this tool's own code rather than quicktype, whose schemas hide nested objects behind $ref definitions named after guessed types.
  • Choose 2020-12 or draft-07 for the $schema line; objects are written inline, so the rest of the schema is the same in both.
  • Strict mode lists every property as required, makes the optional ones nullable, closes every object with additionalProperties false, wraps a non-object root under an items key and drops formats OpenAI does not document, such as uri.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

Why is a field optional when it appears in almost every record?
Because it was missing from at least one sample, and the schema describes what your data actually did. If the field is really mandatory, the sample that lacks it is the bug. Remove that record from the input, or add the key to the required list by hand afterwards.
What does OpenAI's strict mode require?
Every property must appear in required, every object must set additionalProperties to false, and the root must be an object rather than an array or anyOf. Optional values are expressed as a type that includes null. Only some string formats are supported — date-time, date, time, duration, email, hostname, ipv4, ipv6 and uuid — which is why this tool drops uri there.
Why does strict mode complain about an empty array?
An empty array tells the inference nothing about its items, and strict mode cannot accept an items schema that allows anything. Put one realistic element in that array in your sample and run it again. Outside strict mode the array is written with an open items schema instead.

The open-source behind it

This tool is a self-contained implementation. glideapps/quicktype (Apache-2.0) does the same job as a library — if you need this behaviour inside your own program, start there rather than calling a web page.

glideapps/quicktype

Also known as

  • json to json schema
  • json schema generator
  • generate json schema from json
  • structured outputs schema
  • function calling schema
  • openai strict schema