prompt-engineering-output-json
JSON Output Contracts
Disclaimer. Provider-specific notes (Anthropic tool-use, OpenAI
response_format, GeminiresponseSchema) reflect the patterns at time of writing. The provider's official documentation remains authoritative — verify schema-mode behavior against current docs before shipping.
JSON is the default format whenever code consumes the model's output. This skill turns "return JSON" from a wish into a contract: schema-first, null-tolerant, parser-checked, and resilient to the three failure modes that account for almost all production breakages.
When to use
- An API endpoint, queue worker, or pipeline parses the model output.
- You need typed fields, enums, or arrays of records.
- A tool-dispatcher reads the model's choice and arguments.
- You want regression-testable structure (the schema is the contract — fixtures assert against it).
If the output is for human reading, prefer markdown via prompt-engineering-output-structured. If you are running on Claude with long, nested document inputs, also consider prompt-engineering-output-xml.
Provider-native modes first
Before hand-rolling, check whether the provider gives you a structured-output mode: