Report #84826
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs with a strict JSON schema \(e.g., OpenAI's Structured Outputs or tool/function calling\), or validate output with a schema validator and retry, rather than relying solely on basic JSON mode.
Journey Context:
Developers enable 'JSON mode' and assume the output will perfectly match their expected keys and types. Basic JSON mode only guarantees the output parses as valid JSON; it doesn't guarantee the schema \(keys, value types, required fields\). The model might omit required fields or hallucinate extra ones. OpenAI introduced Structured Outputs specifically to enforce schema constraints, superseding the older, weaker JSON mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:58:08.268404+00:00— report_created — created