MBOX Viewer and Converter
Operator: Abdulla Al Fahad. How tools are built and checked
Gmail Takeout hands you one .mbox file that can run to many gigabytes, and a mail client will either refuse it or spend an hour importing it. Usually you only want a handful of messages from it: a label, a sender, a date range, or everything with an attachment.
This page reads the archive in 8 MB slices, builds a small index of headers, and keeps the message bodies on disk until you open one. Filtering is instant on that index, and the exports write only what you filtered or ticked.
Key features
- Index of date, sender, recipients, subject, X-Gmail-Labels, size and attachment flag for up to 300,000 messages, held at roughly 0.3 KB per message
- Filters for subject, sender or recipient text, a sender, a label, a from and to date, and attachments present or absent
- Message view with headers, plain and HTML bodies, inline pictures and attachments, with HTML shown in a locked frame and remote pictures blocked
- Exports of the filtered or ticked messages as a ZIP of .eml files, a CSV index and a ZIP of attachments, with a PDF of any single message
- Decoding of quoted-printable, base64, character sets, RFC 2047 headers, multipart alternative, related and mixed bodies and attached messages
How mbox archives mark messages and labels
An mbox file is every message in a row, each starting with a line that begins 'From ' and carries a sender and a time. The reader only treats such a line as a boundary when it follows a blank line and contains a time of day, which is what the mboxo, mboxrd and Takeout writers produce. Inside a body, a line that began with From was written as '>From' (or '>>From' in mboxrd); when a message is opened or exported, exactly one '>' is taken back off those lines.
The index records the position of each message, so a message is read again with File.slice when you open it. Messages over 64 MB are not parsed in full: the viewer reads the first 256 KB and says so, and the .eml export leaves them out and tells you which one.
How it works
Scanning walks the file in slices with a small overlap so a boundary on a slice edge is not missed, decodes each slice as single-byte text only to find line starts, and parses the first 16 KB of each message for its headers.
Labels are interned: every distinct label is stored once and each message keeps a short list of label numbers, which is what keeps a 100,000-message index small.
Filtering loops over the index arrays and returns the matching positions without copying messages, so changing a filter on a large archive does not re-read the file.
When this helps
- Someone closing a Google account needs every message with an attachment from the label Receipts for tax year 2023: filter by label and date, export the attachments ZIP, and rename nothing because duplicate names become 'invoice (2).pdf'.
- An archivist has a 6 GB Thunderbird Inbox file and wants a CSV of sender, subject and size for 80,000 messages to find the largest threads.
- A support lead searches a shared-mailbox export for one customer's address and saves the six matching messages as .eml to attach to a ticket.
Opening a file
- Drop the .mbox file onto the page and wait for the scan to report the message count.
- Set the filters: text, sender, label, a date range and the attachment option. The Matching count updates as you type.
- Open a message from the list to read it, or tick messages, or press Select all matching (up to 20,000).
- Press .eml ZIP, CSV index or Attachments ZIP; exports use the ticked messages if any are ticked, otherwise every match.
- For one message as a document, open it and use Save as PDF.
Example
An illustrative mailbox generated for this page, not a real account: 3,000 messages with subjects 'Report 0' to 'Report 2999', 1,500 of them labelled Work
Label Work, Attachments: Has attachments, From date 2023-03-01, To date 2023-04-30, then .eml ZIPMatches and the ZIP
Label alone leaves 1,500 messages; adding the attachment filter leaves 300; the two-month range leaves 50. The ZIP holds 50 files starting 000016-2023-04-16-Report 15.eml, and the CSV row for message 16 reads 2023-04-16T10:00:00Z, Person 15, Report 15, Travel; Work, yes.Limits
Filters read headers only. Text that appears only in a message body will not be found, and a message without a readable Date header never matches a date range.
The attachment flag comes from the top-level content type, so a message whose attachment sits inside a nested multipart can show 'No attachment' in the list even though the message view finds the file.
- Search on the sender box to find mail from a domain: typing '@example.com' matches every address at it.
- Exports are limited to 20,000 messages and 500 MB of message bytes, so for a huge range split it by date and export in passes.
Common errors and how to fix them
- "This file does not start with an mbox 'From ' line"
- The file is not an mbox archive, or it was saved with a leading blank line. Gmail Takeout's file is named 'All mail Including Spam and Trash.mbox'; folders from Apple Mail are .mbox packages, so choose the file named mbox inside the package.
Best practices
- Tick or filter first, then export, so each ZIP covers one question such as one label or one quarter.
- Keep the CSV index next to the .eml ZIP; the message number column points back to the position in the original archive.
What the 8 MB slice means for memory
Only the slice being scanned and the index are in memory while a file is read, so a 10 GB archive needs the same working space as a 100 MB one plus its index. Opening a message loads that message alone, and an export holds the messages it has written so far in the growing ZIP, which is why the exports have a byte cap.
Frequently asked questions
Does it rewrite or change my archive?
No. The file is only read with slices and nothing is written back; every export is a new file.
How are the exported .eml files named?
By message number, date and subject, such as 000016-2023-04-16-Report 15.eml. Characters that are not allowed in file names become underscores and a clash gets '(2)'.
Is there a version for a single message or an Outlook file?
For one .msg use the Outlook MSG Viewer, and for a .pst data file the PST File Viewer; a single saved .eml goes through EML to PDF.