# MBOX Splitter

Paste an mbox archive and split it into individual .eml messages with suggested filenames. List what is inside, pull out one message, or export JSON — all local.

## Run it

- **CLI:** `gizza tool mbox-splitter "From alice@example.com Mon Sep 03 10:00:00 2018
From: Alice <alice@example.com>
Subject: Quarterly report
Message-ID: <a1@example.com>
Date: Mon, 3 Sep 2018 10:00:00 +0000

first body

From bob@example.com Mon Sep 03 11:00:00 2018
From: Bob <bob@example.com>
Subject: Lunch?
Message-ID: <b2@example.com>
Date: Mon, 3 Sep 2018 11:30:00 +0000

second body"`
- **Web:** https://gizza.ai/tools/mbox-splitter/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/mbox-splitter/tool.json

## Inputs

- `mbox` — MBOX text _(field)_
- `output` — What to return _(field)_
- `naming` — Suggested filenames _(field)_
- `message` — Single message number (0 = all) _(field)_
- `unescape_from` — Undo >From body quoting _(field)_
- `keep_postmark` — Keep the From postmark line _(field)_

## Output

- Split messages (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `mbox` — MBOX text
- `output` — What to return
- `naming` — Suggested filenames
- `message` — Single message number (0 = all)
- `unescape_from` — Undo >From body quoting
- `keep_postmark` — Keep the From postmark line

Example: `https://gizza.ai/tools/mbox-splitter/?mbox=From%20alice%40example.com%20Mon%20Sep%2003%2010%3A00%3A00%202018%0AFrom%3A%20Alice%20%3Calice%40example.com%3E%0ASubject%3A%20Quarterly%20report%0AMessage-ID%3A%20%3Ca1%40example.com%3E%0ADate%3A%20Mon%2C%203%20Sep%202018%2010%3A00%3A00%20%2B0000%0A%0Afirst%20body%0A%0AFrom%20bob%40example.com%20Mon%20Sep%2003%2011%3A00%3A00%202018%0AFrom%3A%20Bob%20%3Cbob%40example.com%3E%0ASubject%3A%20Lunch%3F%0AMessage-ID%3A%20%3Cb2%40example.com%3E%0ADate%3A%20Mon%2C%203%20Sep%202018%2011%3A30%3A00%20%2B0000%0A%0Asecond%20body&output=files&naming=index&message=0&unescape_from=true&keep_postmark=true`

---

## About this tool

An mbox file is one long text file holding many emails end to end. Mail clients
and export services — Thunderbird, Apple Mail, Gmail Takeout, mailing-list
archives — all hand you a single `.mbox`, which is awkward when you only want
one message, or when the thing you need to open the mail with expects one file
per message. This tool splits the archive back into the individual messages it
contains, each a ready-to-save `.eml` with a suggested filename.

Messages are separated the classic way: a `From ` postmark line at the start of
a line. The space after `From` is what distinguishes the separator from a
`From:` header, so header lines never split a message by mistake. Each message
is then sliced out **verbatim** — headers, MIME structure, and base64
attachments are copied byte for byte, never re-serialized — so what you save is
a faithful copy of the original mail. The postmark line itself is dropped by
default, because a `.eml` file is a bare RFC 5322 message; turn on **Keep the
From postmark line** if you want to reassemble an mbox later.

Four things you can ask for:

- **Every message as .eml text** — each message under a
  `===== 001-name.eml (N bytes) =====` header, so you can copy one out or save
  the whole thing.
- **Index of what is inside** — a numbered table of filename, date, sender,
  subject, and size, with no bodies. Useful for checking an archive before
  doing anything with it.
- **JSON records** — `{ index, filename, subject, from, date, bytes, eml }` per
  message, for scripting.
- **One raw message only** — combine with a message number to get exactly one
  `.eml` and nothing else. This is the mode to use with the Download link.

Filenames follow whichever scheme you pick — numbered, subject, date, or
Message-ID — and always keep the `001-` index prefix so the original archive
order and filename uniqueness survive. Subjects written as RFC 2047 encoded
words (`=?utf-8?q?Caf=C3=A9?=`) are decoded first and then slugged to portable
lowercase ASCII.

Exporters escape body lines that begin with `From ` by writing `>From ` (the
mboxo/mboxrd convention). **Undo >From body quoting** is on by default so bodies
match the message as sent; switch it off if you want the archive bytes exactly
as they were stored.

Everything runs locally in your browser as WebAssembly — the archive is never
uploaded.

**Limits:** one run splits at most 2000 messages, and input arrives as text
through the field above, so a multi-gigabyte export should be cut down first.
The tool returns text, not a ZIP of files: to save a single message, choose
**One raw message only** with a message number and use the Download link, then
rename the downloaded file to `.eml`.

### Worked example

Input:

```text
From alice@example.com Mon Sep 03 10:00:00 2018
From: Alice <alice@example.com>
Subject: Quarterly report
Message-ID: <a1@example.com>
Date: Mon, 3 Sep 2018 10:00:00 +0000

Numbers attached.

From bob@example.com Mon Sep 03 11:30:00 2018
From: Bob <bob@example.com>
Subject: Lunch?
Message-ID: <b2@example.com>
Date: Mon, 3 Sep 2018 11:30:00 +0000

One o'clock?
```

With **Index of what is inside** and date filenames, the output is:

```text
2 message(s)

  1. 001-2018-09-03-1000.eml
     date:    2018-09-03T10:00:00+00:00
     from:    alice@example.com
     subject: Quarterly report
     size:    141 bytes

  2. 002-2018-09-03-1130.eml
     date:    2018-09-03T11:30:00+00:00
     from:    bob@example.com
     subject: Lunch?
     size:    124 bytes
```

Switching to **One raw message only** with message `2` returns Bob's message on
its own, starting at `From: Bob <bob@example.com>` — no postmark, no other mail.

## FAQ

<details>
<summary>How does the tool know where one message ends and the next begins?</summary>

It splits on the mbox postmark: a line starting with `From ` — the word `From`
followed by a space — at column 0. That is the separator every mbox writer
emits. A `From:` header has a colon instead of a space, so it is never mistaken
for a separator. If your text has no postmark at all, it is treated as a single
message, which means a lone `.eml` pasted in still works.

</details>

<details>
<summary>Are attachments and formatting preserved?</summary>

Yes. Each message is copied out of the archive verbatim, including MIME
boundaries, `Content-Type` headers, and base64-encoded attachment parts. The
tool only reads the Subject, Date, and Message-ID headers, and only to build the
suggested filenames — it never rewrites the message. Saving one of the output
blocks as a `.eml` gives you a file your mail client can open with attachments
intact.

</details>

<details>
<summary>Can I download every message as separate files or a ZIP?</summary>

Not from this page — it produces text, so a multi-file download has nowhere to
go. What you can do is choose **One raw message only**, set the message number,
and use the Download link to save that message (rename it from `.txt` to
`.eml`). For a whole archive, the `.eml` text mode prints every message under a
labelled header, which you can save once and split with a script, or run the
command-line version once per message and redirect the output.

</details>

<details>
<summary>What does the `>From ` option do?</summary>

Because a body line beginning with `From ` would look like a message separator,
mbox writers escape it as `>From ` (and an already-escaped `>From ` becomes
`>>From `). Leaving **Undo >From body quoting** on strips one level of that
quoting so the body reads as it was sent. Turn it off when you want to see the
stored bytes unchanged — for example when comparing against the original file.

</details>

<details>
<summary>Should I keep the postmark line?</summary>

Keep it off if you are producing `.eml` files: an `.eml` is a bare RFC 5322
message and the postmark (`From sender Mon Sep 03 10:00:00 2018`) is an mbox
container artifact that some mail clients display as junk. Turn it on when you
want each piece to be a valid one-message mbox — for instance if you plan to
concatenate a subset back into a smaller archive.

</details>

<details>
<summary>Why did I get a message-count error?</summary>

Two caps guard the browser. An archive with more than 2000 messages is rejected
outright — split the file first. And asking for a single message number larger
than the archive holds is an error that tells you how many messages there
actually are, so you can pick a valid one; use `0` to get every message.

</details>

## Related tools

- [Gmail Takeout mbox → CSV / JSON](https://gizza.ai/tools/gmail-takeout-parser/): Turn a Google Takeout Gmail .mbox export into CSV or JSON — one row per message with date, from/to/cc, subject and Gmail labels. In-browser, no upload.
- [Parse a Postal Address](https://gizza.ai/tools/address-parse/): Parse a freeform postal address into street, unit, city, region, postcode, and country fields. Local, rule-based, and browser-only.
- [Authorization Header Decoder](https://gizza.ai/tools/authorization-header-decode/): Decode an HTTP Authorization header: Basic to username and password, Bearer token structure, Digest and AWS SigV4 params. Free, in your browser.
- [Basic Auth Header Generator](https://gizza.ai/tools/basic-auth-header-generator/): Generate an HTTP Basic Authorization header from a username and password — base64(user:pass) per RFC 7617. Runs in your browser, nothing is sent, free.
- [Calendar Free/Busy Overlap](https://gizza.ai/tools/calendar-freebusy-overlap/): Paste two .ics calendars and list the time slots where both are free — working hours, minimum meeting length, timezones and DST handled. Free and in-browser.
