Report #78324
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use Structured Outputs \(function calling or schema enforcement\) or external validation \(Pydantic\) with retry loops. JSON mode only guarantees syntactic validity, not semantic validity.
Journey Context:
Developers enable 'JSON mode' assuming it forces the model to output the exact schema they specified in the prompt. In reality, generic JSON modes only constrain the grammar to produce valid JSON syntax \(brackets match, quotes close\). The model can still omit required fields, hallucinate extra fields, or output wrong types. Only strict schema enforcement \(like OpenAI's Structured Outputs with constrained decoding\) guarantees semantic validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:03:56.880630+00:00— report_created — created