JSON Mode vs Strict Structured Outputs
The difference between JSON mode and strict schema structured outputs, why a valid format is not a correct answer, and what your code must still check, for your AI interview.
In short
JSON mode makes the model return valid JSON, with no set shape. Structured outputs take a JSON Schema you supply and hold completed replies to it, but your code still checks refusals, cut-off replies and business rules.
10 min readIntermediateCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
JSON mode makes a model return valid JSON, so the reply should parse, but the field names and types can still be wrong. Structured outputs go further: you give a JSON Schema, and a completed reply has to match it. Neither one checks your business rules. On a card dispute form, I check the amount against the transaction in code, and I retry a cut-off reply.
There are two ways to ask a model for JSON, and they promise different things. JSON mode keeps the reply to valid JSON, so it should parse, apart from edge cases your code must catch. But the field names and types can still drift from what your code expects. Structured outputs go further. You give a JSON Schema, and a completed reply has to match it, so required fields and enum values follow your schema.
Neither one checks the facts. A schema can say the amount is a number, but it cannot say the amount must stay under the original transaction. Refusals and replies cut off at the length limit also need handling in your code, and, with Anthropic's structured outputs, enum values can come back with different capitals.
On a card dispute form, I would use structured outputs where the vendor supports them, then run my own checks: the amount against the transaction, the dispute type, and a retry or a person when the reply fails. The schema keeps the shape tidy. The code decides what the card system is allowed to accept.
So JSON mode gives you data you can parse. A strict schema gives you data in the right shape. Your code still has to check it.
What is the difference, in plain words?
JSON is a plain text format for data: keys, values and curly brackets that any program can read. Your app reads a reply with a parser, and a reply with a missing bracket makes the parser fail.
JSON mode is the basic setting. The model is kept to valid JSON, except in edge cases your code must detect and handle. A JSON Schema is a written contract for the shape: which fields exist, their types, and which are required. Structured outputs take that contract and hold completed replies to it.
Think of a bank's dispute form. JSON mode is a form the scanner can read. A strict schema is a form where each box takes only the right kind of answer. Neither form checks the figures against the account. That is the clerk's job, and in an AI system the clerk is your code.
Key words
- JSON
- A text format for data, written as keys and values in curly brackets.
- JSON Schema
- A written contract for a JSON reply: its fields, their types, and which are required.
- JSON mode
- The basic setting: the reply is meant to be valid JSON, and nothing more about its shape.
- Structured outputs
- A completed, non-refusal reply is held to a JSON Schema you supply.
How do the two modes differ?
Both aim at the same goal: your code gets data it can read. They promise different things, so say exactly what each one covers.
- JSON mode
Valid JSON only
The reply should parse, but field names and types can still drift from what your code expects.
- Structured outputs
Completed replies match
Required fields and enum values follow the JSON Schema you supply.
- Which to use
Structured, when you can
OpenAI advises structured outputs over JSON mode when it is possible.
“While both ensure valid JSON is produced, only Structured Outputs ensure schema adherence.”
OpenAI
“Without structured outputs, Claude can generate malformed JSON responses or invalid tool inputs that break your applications.”
Anthropic
Two ways to get JSON, one check in code
Your request
asks for one answer as JSON
JSON mode
Valid JSON
keys and types can still drift
Structured outputs
Matches your schema
fields and enum values follow it
Your code
checks business rules the schema lacks
Used by the system
only after your checks pass
- 1JSON mode keeps the model to valid JSON, nothing more.
- 2Structured outputs hold completed replies to the JSON Schema you wrote.
- 3A JSON mode reply still needs its fields and rules checked.
- 4A schema reply still needs the same checks in your code.
- 5Only checked replies go on to the system.
Where do replies still go wrong, and what does it cost?
A schema narrows the reply. It does not check the facts, and it does not cover every bad case. These are the gaps to name in an interview.
- 1
The model refuses
A refusal can come back instead of the schema, and it takes precedence over the schema. Check for it before you read any fields.
- 2
The reply is cut off
A reply that stops at the length limit may be incomplete and not match your schema. Treat it as a failure, and retry with more room.
- 3
A word has the wrong capitals
Enum values can come back with different capitals, such as Approved for approved. Anthropic's structured outputs do not guarantee capitalisation, so normalise in code or reject the reply.
- 4
Your rules are not in the schema
A schema cannot know your limits, like the original transaction amount or who may approve. Your code checks those.
- 5
The first call is slower
OpenAI and Anthropic both say the first use of a schema adds delay. Anthropic caches its compiled grammar for 24 hours from last use, so later requests are faster.
“Your application still needs to handle refusals, incomplete responses, and API errors, and validate any business rules that the schema does not express.”
OpenAI
“The output might be incomplete and not match your schema.”
Anthropic
Here is the check in plain Python. The model is not run. These are four replies a dispute bot might send, and the code decides what passes.
# A card dispute bot proposes one form. The model is not run here;
# these are four replies it might send, and the code decides.
import json
TRANSACTION_AMOUNT = 120.00 # from the card system, never from the model
DISPUTE_TYPES = {"fraud", "duplicate", "not_received"}
REPLIES = [
'{"transaction_id": "T-88121", "dispute_type": "fraud", "amount": 120.0}',
'{"transaction_id": "T-88121", "dispute_type": "Fraud", "amount": 120.0}',
'{"transaction_id": "T-88121", "dispute_type": "fraud", "amount": 540.0}',
'{"transaction_id": "T-88121", "dispute_type": "fraud", "amou',
]
def check(reply):
try:
data = json.loads(reply)
except json.JSONDecodeError:
return "REJECT: cut off or not JSON, retry or ask a person"
if not isinstance(data, dict):
return "REJECT: not an object"
if data.get("dispute_type") not in DISPUTE_TYPES:
return "REJECT: unknown dispute type " + str(data.get("dispute_type"))
amount = data.get("amount")
if not isinstance(amount, (int, float)) or amount > TRANSACTION_AMOUNT:
return "REJECT: amount missing or above the transaction"
return "OK: dispute for " + str(amount)
for reply in REPLIES:
print(check(reply))Output
OK: dispute for 120.0 REJECT: unknown dispute type Fraud REJECT: amount missing or above the transaction REJECT: cut off or not JSON, retry or ask a person
Where a neat reply can still fail
Model reply
parses, and fits the schema, or not
Known ways to fail
Cut off at length limit
stops before the schema ends
Model refuses
a refusal can replace the reply
Wrong capital letters
Approved, not approved
Fits the schema
fields present, types right
Retry or ask a person
never pass a bad reply on
Check business rules
amount, dates, limits, approvals
Used by the system
only when every check passes
- 1A reply with one of the known problems goes this way.
- 2A reply with the right fields and types moves on.
- 3A bad reply is retried, or passed to a person.
- 4A reply that fits the schema still gets its rules checked.
- 5Only a reply that passes every check is used.
How would you choose for a card dispute form?
A card dispute bot fills in a form: the transaction, the dispute type and the amount. The card system accepts only up to the original amount, and the form is filed with it straight away.
- Plain JSON, no checks
Parses, then breaks later
A capital letter or a sum above the transaction reaches the card system as if it were fine.
- Schema and code checks
Bad replies are caught
The schema fixes the shape. Your code checks the amount against the transaction before anything is filed.
Tip
Say that the schema is not the last check. The amount rule lives in your code, where the model cannot change it.
What does the interviewer want to hear?
A strong answer covers
- JSON mode means valid JSON. Structured outputs also hold completed replies to a schema you supply.
- A schema fixes the shape, not whether the values are true.
- Refusals, cut-off replies and business rules still need code.
- Name the vendor feature you would use, and what it does not promise.
- Mention the cost: structured outputs add delay on a schema's first call.
Common traps
Trap"JSON mode means the data is correct."
BetterIt means the reply should parse. The field names and values can still be wrong.
Trap"A schema stops the model making things up."
BetterA schema fixes the shape. A made-up number still fits a number field.
Trap"The schema handles every error."
BetterRefusals, cut-off replies and business rules need checks in your code.
Can you spot the gap?
Spot the gap
Your schema says amount is required and must be a number. Which reply can still do harm?
Quick check
Your dispute bot is moving to structured outputs. What else does it need to be safe?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q085How do you get reliable JSON output?12 min
- Q234How should an app handle refusals?Coming soon
- Q478Parse and validate LLM JSON, retrying on failure.Coming soon
- Q448How do you extract structured data from documents and images?Coming soon
- Q176How should an agent handle tool errors and retries?14 min
Learn it in depth
Last updated on 26 November 2026
Building a bot that fills in forms or records?
I design and build AI products and agents: the schema, the checks in code and the path to a person when a reply fails. Book a short call and tell me what your bot needs to write.