# EML to JSON: Parse Email Files to Clean JSON (`eliai/eml-to-json`) Actor

Parse .eml email files to JSON: from, to, cc, subject, date, text and HTML body, links, thread IDs and attachment names, types and sizes. Give EML file URLs or paste raw email. One row per email. For developers, AI agents and support or e-discovery teams. Failed items are never charged.

- **URL**: https://apify.com/eliai/eml-to-json.md
- **Developed by:** [Broke to Built](https://apify.com/eliai) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 email parseds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### EML to JSON: Parse Email Files to Clean JSON

**Give .eml file URLs or paste raw email source. Get sender, recipients, subject, date, plain-text and HTML body, links, thread IDs and attachments as clean JSON. One row per email.**

| You give it | You get back | You pay (Free plan) |
|---|---|---|
| EML file URLs or raw RFC 822 email text | `from`, `to`, `cc`, `bcc`, `replyTo`, `subject`, `date`, `messageId`, `inReplyTo`, `references`, `text`, `html`, `links`, `attachments`, key headers | **$0.002 per email parsed** |

Inputs that are not emails are written to the dataset with the reason and are never charged.

#### Try it in one click

The input form is pre-filled with a sample email. Press **Start**.

```json
{}
```

You get a row like this (body shortened):

```json
[
  {
    "ok": true,
    "from": [{ "name": "Ada Example", "address": "ada@example.com" }],
    "subject": "Invoice 1042 is ready",
    "text": "Hi, your invoice 1042 is ready...",
    "links": ["https://example.com/invoices/1042"],
    "attachments": []
  }
]
```

### Who this is for

- **AI agents and RAG pipelines** that ingest exported mail and need structured fields, not MIME soup.
- **Legal, compliance and e-discovery** work on exported mailboxes.
- **Developers** turning saved emails into tickets, leads or records.

### Input

| Field | What it does |
|---|---|
| `eml` | One email as raw text or a URL to an .eml file. |
| `emlUrls` | Many .eml URLs at once. |
| `includeHtml` | Return the HTML body too (default on). |
| `saveAttachments` | Save attachments to run storage and return download links. |
| `maxFileSizeMb` | Skip files larger than this. |

### Pricing

Pay per event: **$0.002 per email parsed** plus a tiny $0.00005 start fee. No subscription.

Built by [Broke to Built](https://broke2builtai.com). Questions: eli@broke2builtai.com.

# Actor input Schema

## `eml` (type: `string`):

One email as raw MIME text, the contents of an .eml file. Leave empty if you only use EML file URLs.

## `emlUrls` (type: `array`):

Public .eml file URLs to download and parse. One JSON row per email.

## `includeHtml` (type: `boolean`):

Add the HTML body to each row next to the plain text.

## `saveAttachments` (type: `boolean`):

Store each attachment in the run's key-value store and add a download URL. Off by default: you still get name, type and size.

## `maxFileSizeMb` (type: `integer`):

Larger downloads are skipped, recorded and never charged.

## Actor input object example

```json
{
  "eml": "From: \"Ada Example\" <ada@example.com>\r\nTo: Ops Team <ops@example.org>\r\nSubject: Invoice 1042 is ready\r\nDate: Tue, 10 Nov 2026 14:05:00 -0500\r\nMessage-ID: <sample-1042@example.com>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nHi team,\r\n\r\nInvoice 1042 for $250.00 is ready at https://example.com/invoices/1042\r\n\r\nAda",
  "emlUrls": [],
  "includeHtml": true,
  "saveAttachments": false,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `results` (type: `string`):

One row per input. Export as JSON, CSV or Excel from the dataset view.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("eliai/eml-to-json").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("eliai/eml-to-json").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call eliai/eml-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eliai/eml-to-json"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/JaLbR1dmSg63LOfTP/builds/yI2N5MVQZLCvDNgWq/openapi.json
