New Tool Radar

AI Concepts

How to Check JSON Mode Against Structured Outputs for Schema Fit

Compare JSON mode with Structured Outputs on the same schema, so you can see which one actually keeps the shape you asked for.

Schematic illustration with three step boxes: send the same schema twice, count the shape failures, and choose by the failures.

JSON mode guarantees valid JSON but does not enforce a schema, so a reply can be valid JSON with missing keys or invented enum values. Structured Outputs is the evolution of JSON mode: it constrains the output to your supplied JSON Schema, and OpenAI recommends it whenever it is available. The difference shows up in a head-to-head test on the same schema.

Before you start

An OpenAI API key, a model that supports both modes, and a schema with required keys and an enum.

Send the same request in both modes

Write one schema with three required keys and one enum field, then send the same prompt twenty times in JSON mode and twenty times with Structured Outputs. Keep the model and the temperature fixed.

Use a prompt that tempts the model to add extra keys or drop one, such as asking for a short summary alongside the fields.

Count the shape failures

For each mode, count how many replies are valid JSON, how many have all required keys, and how many keep the enum values valid. Record the three counts separately: a reply can be valid JSON and still fail the schema.

Note any reply that adds friendly text around the JSON: JSON mode does not stop that, and it breaks a plain parser.

Choose by the failures, not the marketing

If JSON mode drops keys or invents enums even once in twenty, use Structured Outputs for that schema. The cost of one bad parse in production is usually higher than the cost of the newer feature.

Keep JSON mode only where the schema is trivial or the model does not support Structured Outputs.

Practice check: fictional Maple Corner order schema, 20 calls per mode

The table below is fictional practice material, worked out by hand from the stated mode rules. It is the expected result for the practice calls, not a run of any API.

Check JSON mode Structured Outputs Verdict
Valid JSON 20 of 20 20 of 20 Tie
All required keys 17 of 20 20 of 20 Structured wins
Enum values valid 18 of 20 20 of 20 Structured wins
No extra text 19 of 20 20 of 20 Structured wins

Both modes return valid JSON 20 of 20, but JSON mode drops required keys 3 times and invents enum values twice. Structured Outputs holds the shape on all 20 calls, so it is the choice for this schema.

Expected result. UNTESTED: the counts in the practice table are worked out by hand, not measured by running the OpenAI API. Send your own schema twenty times in each mode, count the shape failures separately, and choose by the failures.

Limits

  • Only Structured Outputs enforces the schema; JSON mode enforces JSON syntax only.
  • Structured Outputs needs a recent model snapshot, while JSON mode works on older models too.

Sources

See all