Report #74023
[counterintuitive] Does JSON mode guarantee the LLM output matches my schema
Use Structured Outputs \(e.g., provider-specific strict schema enforcement or constrained decoding\) rather than basic JSON mode. Always validate the output against your JSON schema on the client side as a fallback.
Journey Context:
Developers enable 'JSON mode' assuming it forces the model to adhere to a specific schema \(e.g., required fields, specific enums\). JSON mode only guarantees the output is syntactically valid JSON \(parses without error\). The model will frequently omit required fields or hallucinate invalid enum values. Providers have recently introduced strict 'Structured Outputs' that constrain the grammar generation to match a provided JSON schema, which actually solves this, but basic JSON mode does not.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:50:36.818556+00:00— report_created — created