Anything that consumes model output programmatically needs a predictable shape, and asking for one in the prompt gets you a predictable shape most of the time. Most of the time is fine for a person reading an answer and unacceptable for code that has to parse it.
What goes wrong with prompted JSON?
- Preamble. A sentence before the JSON explaining what follows.
- Code fences. Markdown wrapping that has to be stripped.
- Trailing commentary. An offer to explain further, after the closing brace.
- Field drift. A key named slightly differently on one run in fifty.
- Type inconsistency. A number as a string, or a single item where an array was expected.
Each is rare individually and collectively they guarantee failures at volume.
What is the proper mechanism?
Schema enforcement, offered by the major providers under names such as structured outputs or JSON mode. You supply a schema and the generation is constrained so that only valid output can be produced, rather than the model being asked to comply.
This is a different guarantee entirely. Instruction is a request; constrained decoding is a property of how the tokens are sampled.
How does tool use relate to this?
It is the same machinery. Defining a function with typed parameters and letting the model call it produces a validated structure, and many people use tool definitions purely to get reliable extraction rather than to call anything.
Where structured output mode is unavailable, a single tool definition is often the most reliable route.
What if the provider does not support it?
Then instruct tightly and validate hard. Ask for only the JSON with nothing before or after, give one example of a correct response, and parse the result with a schema validator that rejects anything malformed.
Retry on failure with the validation error included in the follow-up, which resolves most cases in one additional call.
Should the schema include a reasoning field?
Frequently, and put it first. A field where the model explains its choice before giving the answer improves quality on judgement tasks, because the reasoning is generated before the conclusion and conditions it.
Placing it after the answer does the opposite: the conclusion is already fixed and the explanation is a justification. The ordering of fields in a schema is not cosmetic, and this is the clearest example of it.
How should you design the schema?
Flat and explicit. Deeply nested structures produce more errors, optional fields invite omissions, and enumerated values work far better than free text where the set is known.
Include a field for uncertainty. A schema requiring every value to be present forces the model to invent, where a nullable field plus a reason field lets it tell you something was missing.
Does structuring hurt quality?
Sometimes, and it is worth knowing. Constraining output can reduce reasoning quality on hard problems, since the model is producing a fixed shape rather than thinking in prose.
The usual remedy is a two-stage approach: one call to reason freely, a second to convert the conclusion into the schema. That costs an extra call and recovers the quality.
What about numbers in structured output?
Treat them as unverified. A schema guarantees that a field contains a number, not that the number is right, and a well-formed response is more convincing than a paragraph while being no more reliable.
Anything calculated should be computed in code from extracted values rather than produced by the model.
How do you handle lists and optional fields?
By being explicit about the empty case. A schema expecting an array of findings will get findings, and a model that found none will frequently invent one rather than return an empty list, because returning nothing feels like failure.
Stating that an empty array is a valid and expected answer resolves it. The same applies to optional fields: without a stated rule, the model chooses between omitting a field and filling it plausibly, and it usually fills it.
What should you always do?
Validate every response before using it, log the ones that fail, and keep the raw output. When something breaks in production, the parsed object tells you nothing and the original response usually makes the cause obvious in seconds.