damngoodprompts

Structured output prompting

How JSON mode, schemas, and prose instructions fit together across current model APIs.

Last reviewed: August 10, 2026

The concept

Structured output means the model returns data in a shape your software can parse. Modern APIs increasingly support schema-constrained output, which is different from asking politely for JSON in prose. For a task recipe that uses this pattern, see structured data extraction.

The prompt still matters. The schema defines the container, but the instructions define how to decide what goes inside it.

The current approach

Use a schema feature when the provider offers one. OpenAI documents Structured Outputs, Google documents Gemini structured output, and Anthropic documents Claude structured outputs.

Prompt the judgment rules separately:

Extract the issue category from the ticket. Use "billing" only when money,
invoice, refund, plan price, or charge language appears. Use "account" for login,
password, identity, or access problems. Use "other" when neither applies.

Then let the schema handle the shape.

For high-volume workflows, this also connects to which model for fast, cheap, high-volume tasks.

When a schema is not available

Ask for JSON only, include the exact keys, and tell the model what to do with missing values. Validate the result in code anyway.

Return only JSON with these keys: category, urgency, summary, missing_fields.
Use null for unknown scalar values and [] for no missing fields.

This is weaker than provider-enforced structured output, but it is still better than “format as JSON please.”

What to avoid

  • Treating JSON syntax as data quality.
  • Asking for chain-of-thought inside a JSON field.
  • Allowing free-form extra keys when downstream code expects a known shape.
  • Skipping validation because the model usually returns valid JSON.

Source set