JSON Mode
Downstream code cannot parse 'sure, here is your data…' with a fenced block.
A form that only accepts a filled sheet — not a handwritten letter.
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
Still validate
Scroll inside the frame to explore · use + / − to zoom up to 200%
Parse JSON, then check the shape you actually need.
Key Takeaways
- 1.JSON mode forces the model to emit a JSON object, not markdown. It is a format lock — not a schema lock.
- 2.Still validate. JSON mode can emit extra keys or wrong types. Use it for APIs that must parse; use structured outputs when you need a schema.
- 3.JSON mode constrains tokens toward valid JSON. It does not enforce your schema.
- 4.Prefer structured outputs or a grammar when fields must match. Always parse-and-validate.
Learn elsewhere
- →Structured Outputs
Real Example
Scenario
Classifier returns {"label":"refund","confidence":0.81}. JSON mode kept it parseable. You still reject missing label.
What you would do
In Tool Calling & Function Calling, apply JSON Mode to this scenario: Classifier returns {"label":"refund","confidence":0. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Commands
Commands to Remember
JSON, not markdownNot a schemaValidate after parsePrefer structured outputs for strict fields
Cheat Sheet
Quick recap
quick ref- •Format lock only
- •Parser-friendly
- •Types still your job
- •Step below structured outputs
Common Mistakes
- ✕Trusting JSON mode as schema validation
- ✕Not handling extra keys
- ✕Using JSON mode when you needed an enum field
