A downstream system needs JSON with fixed fields. What is the most reliable approach?
Why A is the answer
Set a JSON schema with structured outputs
Structured outputs return JSON matching your schema in the text block. Prefill returns a 400 on Claude 4.6 models and later.
In detail
- Structured outputs make the reply match your JSON schema.
- That guarantee is stronger than asking in the prompt, and it removes the need for parsing tricks.
- Handle cases such as refusals, where a reply may not match.
Use case
An illustrative scenario, not a real incident.
An order system parses Claude's reply into fields, and a stray sentence breaks it each week. Setting a JSON schema with structured outputs means the reply arrives in the expected shape.
See it in different ways
flowchart LR
A["Document"] --> B["Structured output"]
B --> C["Valid shape"]
C --> D{"Business checks"}
D -->|"Pass"| E["Store"]
D -->|"Fail"| F["Review queue"]flowchart LR
A["Model output"] --> B{"Matches schema?"}
B -->|Yes| C{"Do the values make sense?"}
C -->|Yes| D["Accept"]
C -->|No| E["Review or retry"]flowchart LR S0["Request with schema"] --> S1["Claude generates"] --> S2["Matching JSON"] --> S3["Downstream system"]
Key point: Use structured outputs when another system depends on the format.
Why the other options are wrong
- B. Prefill the reply with an opening brace on every request you send
- Prefill returns a 400 on Claude 4.6 models and later.
- C. Parse the text with a regular expression and retry when parsing fails
- Regular expressions over free text are fragile, and retries add cost.
- D. Ask for JSON in capital letters at the end of the user message
- Capital letters make a request louder, not guaranteed.

