Structured Output
Get JSON, tables, CSV, and precise formats — every time.
What You'll Learn
- How to get consistent, machine-readable output from AI
- JSON, Markdown tables, CSV, and custom formats
- Schema-driven prompting for reliable data extraction
- Handling edge cases and validation
Why It Matters
AI Output You Can Actually Use in Code
Free-form text is great for reading. It's terrible for automation. If you're building workflows, feeding AI output into other tools, or processing data — you need structured output that's consistent and parseable.
The good news: AI is excellent at producing structured data. You just have to ask correctly.
Technique 1
JSON Output with Schema
The most reliable way to get JSON: show the exact schema you want, with descriptions for each field.
Schema-Driven Prompt
Extract product information from the following review and return it as JSON matching this exact schema:
{
"product_name": "string — the product being reviewed",
"rating": "number — 1 to 5, inferred from sentiment if not explicit",
"pros": ["string — list of positive points mentioned"],
"cons": ["string — list of negative points mentioned"],
"would_recommend": "boolean — true if reviewer recommends it",
"summary": "string — one-sentence summary of the review"
}
Return ONLY the JSON object. No explanation. No markdown code fences.
This lesson is for Pro members
Unlock all 300+ lessons across 30 courses with Academy Pro. Founding members get 90% off — forever.
Already a member? Sign in to access your lessons.