Report #4220
[research] How do I get reliable schema-compliant JSON from Claude?
On supported models, use native structured output with output\_config.format.type='json\_schema'. As a fallback, force a single tool with tool\_choice=\{'type':'tool','name':...\} and extract the tool\_use input. Post-validate with Pydantic because Claude silently ignores some JSON Schema constraints \(minLength, pattern, minimum\).
Journey Context:
Claude lacked a native JSON mode for years; forced tool\_use was the production pattern. Native structured output reached GA in early 2026 but is stricter than OpenAI's: no recursive schemas, no numeric/string constraints, 20 strict tools max. Many teams use Instructor to normalize across providers. Put reasoning fields before answer fields or the model commits early.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:01:30.981727+00:00— report_created — created