npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@technical-1/email-archive-parser

v3.0.0

Published

A powerful library for parsing email archives (OLM, MBOX) and detecting accounts, purchases, subscriptions, and newsletters

Downloads

291

Readme

Email Archive Parser

Parse OLM and MBOX email archives and extract structured signal: accounts, purchases, subscriptions, and newsletters.

@technical-1/email-archive-parser is a dependency-light TypeScript library for turning raw email-export files into typed Email objects, then mining those objects for the things people actually care about — which services they signed up for, what they bought, what they pay for monthly, and which senders are newsletters. It runs the same code in Node.js and the browser, streams multi-gigabyte MBOX files without exhausting memory, and ships as both CommonJS and ESM with full type declarations.

Features

  • OLM parsing — reads Outlook for Mac .olm archives (a ZIP container) via JSZip, extracting emails, contacts, and calendar events.
  • MBOX parsing — handles Gmail Takeout, Thunderbird, and Apple Mail exports, including Gmail label extraction and mboxrd >From unescaping.
  • Streaming for large files — MBOX input is processed in chunks (file streams in Node, sliced reads in the browser) so multi-GB archives parse without loading the whole file into memory.
  • Charset-aware MIME decoding — quoted-printable and RFC 2047 encoded-words (=?charset?B/Q?...?=) are decoded byte-accurately through TextDecoder, with surrogate-pair handling so emoji and astral code points survive.
  • Account detection — recognizes 100+ services across streaming, e-commerce, social, banking, development, and communication, with boundary-safe domain matching.
  • Purchase detection — identifies order/receipt/invoice emails, filters out promotional noise, and extracts amounts across 8 currencies (USD, EUR, GBP, JPY, CAD, AUD, INR, CHF).
  • Locale-aware money parsing — correctly reads 1.234,56, 1,234.56, and 1'234.56 by resolving the decimal separator from its position rather than assuming a single format.
  • Subscription detection — finds recurring services, infers billing frequency, normalizes prices to a monthly figure, and only trusts amounts that sit inside a billing context.
  • Newsletter detection — flags newsletters and promotional senders, extracts unsubscribe links, and estimates sending frequency — without misflagging gmail.com/hotmail.com as promotional.
  • Cross-platform — no DOM assumptions; uses Buffer and atob/TextDecoder fallbacks so encoding works in Node and the browser alike.
  • TypeScript-first — every public surface is fully typed, shipped with .d.ts declarations.

Tech Stack

  • Language: TypeScript (^5.3), targeting ES2020
  • Build: tsup — dual CJS + ESM output with type declarations
  • Tests: Vitest
  • Runtime dependency: JSZip (^3.10) for OLM archive extraction

Getting Started

Prerequisites

  • Node.js >= 16

Installation

npm install @technical-1/email-archive-parser

Usage

import { parseArchive } from '@technical-1/email-archive-parser';
import { readFileSync } from 'fs';

// Node.js: parse a Buffer and run all four detectors
const buffer = readFileSync('archive.mbox');
const result = await parseArchive(buffer, {
  detectAccounts: true,
  detectPurchases: true,
  detectSubscriptions: true,
  detectNewsletters: true,
  onProgress: (p) => console.log(`${p.progress}% — ${p.message}`),
});

console.log(`Parsed ${result.emails.length} emails`);
console.log(`Accounts: ${result.accounts?.length ?? 0}`);
console.log(`Purchases: ${result.purchases?.length ?? 0}`);
console.log(`Subscriptions: ${result.subscriptions?.length ?? 0}`);
console.log(`Newsletters: ${result.newsletters?.length ?? 0}`);

parseArchive accepts a File (browser), Buffer, or ArrayBuffer, auto-detecting OLM (a ZIP container) vs. MBOX by filename or magic bytes.

For very large MBOX files in Node, use the file-path streaming entry point directly:

import { MBOXParser } from '@technical-1/email-archive-parser';

const parser = new MBOXParser();
const result = await parser.parseFile('/path/to/huge-archive.mbox', {
  onProgress: (p) => console.log(`${p.progress}%: ${p.message}`),
});

Detectors can also be run on their own against already-parsed emails:

import { PurchaseDetector } from '@technical-1/email-archive-parser';

const purchases = new PurchaseDetector().detectBatch(result.emails);

Migrating to v3

  • Email.date can now be null — and so can Contact.lastEmailDate, Account.signupDate, Subscription.lastRenewalDate, and Newsletter.lastEmailDate. Parsers no longer fall back to the current time for a missing/unparseable Date: header, so null-check before calling Date methods.
  • Subscription.monthlyAmount and Subscription.frequency are now optional and are only present when a billing cadence was actually detected.
  • Email.size is now an uncapped UTF-8 byte count, not a (previously 100,000-capped) character count.

Development

# Install dependencies
npm install

# Run tests (watch mode)
npm test

# Run tests once
npm run test:run

# Build CJS + ESM + type declarations
npm run build

Project Structure

src/
├── index.ts                  # Public exports + parseArchive() convenience entry point
├── types.ts                  # Email, Account, Purchase, Subscription, Newsletter types
├── utils.ts                  # MIME/RFC 2047 decoding, address/domain helpers
├── parsers/
│   ├── mbox.ts               # Streaming MBOX parser (Gmail/Thunderbird/Apple Mail)
│   └── olm.ts                # OLM (Outlook for Mac) ZIP archive parser
└── detectors/
    ├── account.ts            # Account/signup detection
    ├── purchase.ts           # Purchase/receipt detection + multi-currency amounts
    ├── subscription.ts       # Recurring-subscription detection
    ├── newsletter.ts         # Newsletter/promotional detection
    └── domainMatch.ts        # Boundary-safe domain lookup shared by detectors

License

MIT

Author

Jacob Kanfer — GitHub