New Tool Radar

AI Concepts

How to Choose Between Structured Outputs and JSON Mode

Choose Structured Outputs when the field names matter, and JSON mode only when any valid JSON will do.

Schematic illustration of choose between structured outputs and json mode: step one name what must hold, step two compare the guarantees, step three pick the weaker only if it fits.

Both Structured Outputs and JSON mode produce valid JSON, but only Structured Outputs ensures the reply follows your schema: required keys are present and enum values are ones you listed. JSON mode only guarantees the reply parses as JSON. The choice is therefore about what your code needs: the shape, or just parseable text.

Prerequisites

  • The two guarantees written down: schema adherence versus valid JSON only.
  • Your code’s requirements for the reply: which fields it reads.
  • Access to an API that supports Structured Outputs.

Steps

Step 1: Name what must hold

List what your code reads from the reply: field names, types and allowed values. If your code reads a field by name, that field must be guaranteed present.

Step 2: Compare the guarantees

Structured Outputs guarantees the schema: required fields and enum values follow the schema you supply. JSON mode guarantees valid JSON only, so a field can be missing or an enum value invented.

Step 3: Pick the weaker only if it fits

Use JSON mode only when your code tolerates any shape, such as logging a free-form object. Otherwise use Structured Outputs; the OpenAI guide recommends preferring it whenever it is available.

Worked example: Northgate Clinic appointment record

The fictional Northgate Clinic stores appointment records. Its code reads patient, date and time by name.

Requirement JSON mode Structured Outputs
Reply parses as JSON Yes Yes
Field ‘patient’ always present No Yes
Field ‘time’ in HH:MM form No Yes, if the schema says so
Code can rely on the shape No Yes

JSON mode meets 1 of the 4 requirements and Structured Outputs meets all 4, so the clinic uses Structured Outputs for appointment records.

Expected result. You have a written comparison showing which guarantee each option gives, and the choice follows from what your code reads. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • Structured Outputs is available on newer models, starting with GPT-4o; older models may only offer JSON mode.
  • Neither option guarantees the values are true; both need value validation.
  • This guide does not cover function calling, which is a separate way to get structured data.

Sources

See all