Lesson 2 of 3 · Structured Outputs & Reliable AI
JSON Mode vs Structured Outputs
A team migrating from JSON Mode to Structured Outputs discovered the distinction the hard way. Their extraction pipeline used response_format: { type: "json_object" } -- JSON Mode -- which guaranteed valid JSON but nothing else. The model returned valid JSON every time, but the shape of that JSON was unpredictable. Sometimes the array field was called items. Sometimes it was called results. Sometimes the price was a number; sometimes it was a string with a dollar sign. JSON Mode solved one problem (valid JSON) while leaving the harder problem (schema adherence) completely unsolved.
Understanding the precise difference between JSON Mode and Structured Outputs is essential because they solve different problems, and using the wrong one gives you a false sense of security.
JSON Mode: Valid JSON, Unknown Shape
JSON Mode was OpenAI's first attempt at reliable output formatting. It constrains the model to produce valid JSON -- proper syntax, matched brackets, correct quoting. Nothing more.
Structured Outputs: Valid JSON + Schema Adherence
Structured Outputs extend JSON Mode with a critical addition: a JSON Schema that the model must follow. The output is not just valid JSON -- it matches your exact schema.
The Key Differences
| Feature | JSON Mode | Structured Outputs |
|---|---|---|
| Valid JSON syntax | Yes | Yes |
| Specific field names | No | Yes |
| Type enforcement | No | Yes |
| Required fields | No | Yes |
| No extra fields | No | Yes (with additionalProperties: false) |
| Enum constraints | No | Yes |
| Nested object schemas | No | Yes |
| Array item schemas | No | Yes |
| Schema versioning | N/A | Yes (via schema name) |
| Refusal handling | No | Yes |
When to Use JSON Mode
JSON Mode still has valid use cases, though they are narrower than most developers think:
When to Use Structured Outputs
For almost everything in production:
- Any pipeline where downstream code expects specific fields and types
- API responses that feed into typed application code
- Data extraction that inserts into a database
- Classification systems where categories are predefined
- Any system where output format errors have business consequences
If you are starting a new project today, default to Structured Outputs for every API call that returns data your application processes programmatically. Use JSON Mode only during early prototyping when you do not yet know your schema. Then migrate to Structured Outputs as soon as your schema stabilizes.
Migration Path: JSON Mode to Structured Outputs
If you have an existing system using JSON Mode, migration is straightforward:
Migrate existing JSON Mode pipelines to Structured Outputs incrementally. Start with the endpoints that have the most parsing failures or the most complex validation logic -- those benefit most. Keep your existing validation as a safety net during migration, then remove it once you have confirmed Structured Outputs handles all cases.
Remove all validation logic immediately after switching to Structured Outputs. Keep it as a logging-only safety net for a few weeks to verify that the structured output matches what your validation was checking. Once you have confidence, remove the redundant validation to simplify your code.
You have an existing pipeline using JSON Mode that extracts product information from e-commerce listings. The model returns valid JSON, but field names vary ("price" vs "cost" vs "amount"), types fluctuate ("29.99" vs 29.99), and optional fields sometimes appear as empty strings instead of being omitted. Write the migration plan: (1) Define the target JSON Schema with strict: true. (2) List all the validation code you can remove after migration. (3) Identify any edge cases where the structured output might behave differently than your current parsing. (4) Design the rollout strategy -- would you switch all at once or run both in parallel?
Use ← → to navigate, Space to mark complete