Report #24770
[synthesis] No equivalent to OpenAI structured outputs \(JSON schema enforcement\) on Claude - JSON extraction unreliable
Use Claude's tool use as a structured extraction mechanism: define a single tool whose input schema matches your desired JSON structure. Claude will populate the tool input matching the schema, giving you validated structured output. Alternatively, use XML tags plus prefilling for simpler cases.
Journey Context:
OpenAI's response\_format with json\_schema guarantees valid JSON matching a schema — it's enforced at the API level. Claude has no such feature. Asking Claude to 'respond with JSON matching this schema' works sometimes but fails under complexity. The reliable workaround: define a tool with your desired schema as its input parameters, and instruct Claude to use that tool to provide its answer. Claude's tool input is schema-validated, so you get the same guarantee as OpenAI's structured outputs. The tradeoff: this consumes a tool definition slot and adds a tool\_use round-trip to your agent logic. For simple extraction, XML tags with prefilling may be lighter weight. This pattern is officially recommended by Anthropic for structured data extraction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:59:19.814612+00:00— report_created — created