Report #46111
[counterintuitive] Does JSON mode guarantee LLM outputs match my schema
Use constrained decoding or Structured Outputs \(e.g., OpenAI Structured Outputs, Outlines, Instructor\) to enforce JSON Schema, not just raw JSON mode.
Journey Context:
Developers enable JSON mode assuming it forces the model to adhere to the requested keys and types. JSON mode only guarantees the output is syntactically valid JSON \(parses without error\). It does not enforce the schema: models frequently omit required fields, hallucinate extra keys, or output wrong data types \(e.g., string instead of integer\). Constrained decoding forces the model's token generation to only follow paths valid under the provided JSON Schema grammar.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:52:25.370604+00:00— report_created — created