Extraction · beginner
Structured JSON extractor from email
Pull sender, subject, intent, urgency, and action items from a raw email body.
You're indexing inbound email into a CRM and want a consistent JSON schema regardless of how the email is written.
The prompt
Copy this verbatim. Replace the {{ … }} placeholders with your values.
<instructions>
Extract structured data from the email below. Return one JSON object matching <format>.
Output the JSON inside <result> tags. No prose, no markdown fences.
If a field is missing from the email, use null.
</instructions>
<format>
{
"sender_name": "string or null",
"sender_email": "string or null",
"subject": "string",
"intent": "question | request | complaint | other",
"urgency": "low | medium | high",
"action_items": ["string"]
}
</format>
<email>{{ email_body }}</email>
Return inside <result> tags.
Sample input
From: Jane Lee <[email protected]>
Subject: Need invoice copy
Hi — could you resend the May invoice? Our AP needs it by Friday. Thanks, Jane
Expected output
<result>
{
"sender_name": "Jane Lee",
"sender_email": "[email protected]",
"subject": "Need invoice copy",
"intent": "request",
"urgency": "medium",
"action_items": ["Resend May invoice to [email protected] by Friday"]
}
</result>
Notes & tuning tips
- Inline `null` and `|` enums in the schema — Claude respects them.
- `return only inside
tags` is the single most reliable way to dodge markdown fences. - For batch jobs, parallelize at the request level — don't ask for a JSON array of multiple emails in one call.
What this example uses
Tags: <instructions> <format>
Patterns: structured output
More like this
extraction
Invoice / receipt line-item extractor
Convert an OCR'd invoice into structured JSON: vendor, totals, line items.
extractionRésumé → structured JSON
Convert a free-form résumé into a normalized candidate profile.
extractionEmail → calendar event
Detect meeting requests in email and emit a structured event with start/end in ISO format.
Cite this page
Structured JSON extractor from email. claudexml.com. https://claudexml.com/examples/structured-json-extractor/