# Structured JSON extractor from email — Claude XML example

> Pull sender, subject, intent, urgency, and action items from a raw email body.
>
> Source: https://claudexml.com/examples/structured-json-extractor/ · Last updated 2026-05-25

Home / Examples / Structured JSON extractor from email
    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.


```xml
<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


```xml
From: Jane Lee <jane@acme.com>
Subject: Need invoice copy
Hi — could you resend the May invoice? Our AP needs it by Friday. Thanks, Jane
```


## Expected output


```xml
<result>
{
  "sender_name": "Jane Lee",
  "sender_email": "jane@acme.com",
  "subject": "Need invoice copy",
  "intent": "request",
  "urgency": "medium",
  "action_items": ["Resend May invoice to jane@acme.com 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.

      extraction
### Résumé → structured JSON
Convert a free-form résumé into a normalized candidate profile.

      extraction
### Email → 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/`
