Report #88960
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Always validate LLM JSON output against a strict schema \(e.g., Pydantic/Zod\) and use Structured Outputs \(JSON schema constraints\) rather than just basic JSON mode.
Journey Context:
Developers enable 'JSON mode' and assume the output will perfectly match their expected keys and types. JSON mode only guarantees the output parses as valid JSON; it does NOT guarantee the schema \(keys, value types, required fields\). The model might return \`\{ 'error': 'I do not know' \}\` instead of the expected \`\{ 'name': 'string', 'age': 'int' \}\`. Structured outputs with function calling or JSON schema enforcement are required for actual schema guarantees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:54:25.423097+00:00— report_created — created