Course OverviewFree AI CourseBlogReserve Bootcamp Seat
Prompt Engineering · Day 4 of 5 ~65 minutes

Structured Output — Making AI Give You Data, Not Text

Once you can get AI to return structured data — JSON, tables, specific formats — you can actually do something with it. This is the skill that unlocks AI for analytics and automation work.

1
Day 1
2
Day 2
3
Day 3
4
Day 4
5
Day 5
What You'll Build Today

Four extraction prompts: one that returns clean JSON from a contract, one that builds a comparison table from product descriptions, one that uses XML tags to structure complex multi-part analysis, and one that extracts structured data from unstructured customer feedback.

1
JSON Output

Getting Clean JSON from AI

The most common structured output request is JSON. The key is: define the exact schema you want, give an example, and tell the AI to return only JSON (no prose before or after).

Contract Data Extraction → JSON
Extract the following information from the contract below. Return ONLY valid JSON matching this exact schema. Do not include any text before or after the JSON.

Schema:
{
  "parties": {
    "vendor": "string",
    "client": "string"
  },
  "contract_value": "number (annual, USD)",
  "start_date": "YYYY-MM-DD",
  "end_date": "YYYY-MM-DD",
  "auto_renewal": "boolean",
  "termination_notice_days": "number",
  "key_obligations": ["string", "string", "string"],
  "liability_cap": "string (e.g., '2x annual fees' or 'unlimited')"
}

If a field is not found in the contract, use null.

Contract:
[paste contract text here]
Customer Feedback → JSON Array
You are a customer feedback analyst. Extract structured data from the following customer feedback messages. Return a JSON array where each element has this structure:

{
  "feedback_id": "number",
  "sentiment": "positive | neutral | negative",
  "category": "product | support | pricing | onboarding | other",
  "urgency": "low | medium | high",
  "key_issue": "string (1 sentence)",
  "action_required": "boolean"
}

Return ONLY the JSON array. No explanations.

Feedback messages:
1. "The API documentation is excellent but rate limits are killing our use case."
2. "Onboarding took 3 weeks. Should take 3 days."
3. "Your support team responded in 4 minutes on a Saturday. Incredible."
4. "Pricing is fair but we wish there was a mid-tier option."
2
Tables

Comparison Tables from Unstructured Text

Vendor Comparison Table
You are a procurement analyst. I have three vendor proposals (pasted below). Create a comparison table with these exact columns:

| Criteria | Vendor A | Vendor B | Vendor C |
|---|---|---|---|
| Annual cost | | | |
| Implementation timeline | | | |
| SLA uptime guarantee | | | |
| Support tier included | | | |
| Data residency options | | | |
| Contract flexibility | | | |
| Strengths (1-2 words) | | | |
| Weaknesses (1-2 words) | | | |

Fill each cell with a short, specific answer. Use "N/A" if not mentioned. Do not add commentary before or after the table.

Vendor A proposal:
[paste here]

Vendor B proposal:
[paste here]

Vendor C proposal:
[paste here]
3
XML Tags

XML Tags for Complex Multi-Part Prompts

XML tags help the AI understand which part of a long prompt is which. They're especially useful when your prompt contains document input plus instructions, or multiple sections the AI needs to handle differently.

XML Tags — Complex Analysis
You are a business analyst. I'm giving you a competitor announcement and our internal product roadmap. Analyze the competitive implications.

<competitor_announcement>
[paste competitor press release or announcement here]
</competitor_announcement>

<our_roadmap>
[paste your Q3/Q4 product roadmap here]
</our_roadmap>

<instructions>
Provide your analysis in this exact format:

OVERLAP: Which of our planned features does the competitor now offer?
DIFFERENTIATION: What do we still have that they don't?
ACCELERATION: Which roadmap items should we ship faster given this news?
RECONSIDERATION: Which roadmap items should we deprioritize or kill?
MESSAGING: One-paragraph suggested update to our competitive positioning.
</instructions>

Why XML tags work: The AI treats the content between tags as a unit. It won't confuse your instructions with your document content. This is especially important when your document input contains words that could look like instructions.

Today's Exercise

Build 4 Extraction Prompts for Your Work

  • Identify something you read regularly that contains structured information but isn't in a structured format (emails, reports, feedback, contracts, proposals)
  • Define the JSON schema you'd want for that information — what fields would make it useful?
  • Write and test a JSON extraction prompt on a real example from your work
  • Build one comparison table prompt for a recurring decision you face (vendor selection, option comparison, etc.)
  • Write one prompt using XML tags to separate document input from instructions

What You Learned Today

  • JSON extraction: define the schema explicitly, ask for ONLY JSON, handle null fields
  • Table generation: specify exact columns and format, prevents AI from "explaining" the table
  • XML tags: separate document content from instructions in long, complex prompts
  • The pattern that makes AI output programmable: specify structure + say "only return X"
Course Progress
Day 4 of 5 — 80%
Day 4 Complete

Day 5: Prompt Engineering for Production

The final day. Testing, versioning, injection defense, and building a prompt library your whole team can use.

Start Day 5