addressparser vs parse-address
Parsing Address Strings: Email Headers vs Physical Locations
addressparserparse-addressSimilar Packages:

Parsing Address Strings: Email Headers vs Physical Locations

addressparser and parse-address are both utilities for parsing address strings, but they target completely different data domains. addressparser is the industry standard for parsing RFC2822 email address headers (e.g., From: Name <email>), widely used in the nodemailer ecosystem. parse-address is typically used for parsing physical mailing addresses (e.g., 123 Main St, City, Zip) into structured components like street, city, and state. Choosing the wrong one leads to critical data errors, as neither can handle the other's format effectively.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
addressparser041-010 years agoMIT
parse-address0164-257 years agoISC

Parsing Address Strings: Email Headers vs Physical Locations

Developers often search for "address parser" without realizing there are two distinct types of addresses in software: email headers and physical locations. addressparser and parse-address solve these different problems, but their similar names cause frequent confusion. Using the wrong library breaks data flow immediately — an email parser cannot split a street address, and a physical parser cannot handle RFC2822 email groups. Let's compare their domains, APIs, and reliability.

🌐 Domain Focus: Email Headers vs Physical Locations

addressparser is built strictly for email addresses found in SMTP headers.

  • It handles formats like Name <email@example.com>.
  • It supports comma-separated lists and RFC2822 groups.
  • Essential for email clients, servers, and notification systems.
// addressparser: Email header parsing
const addressparser = require('addressparser');

// Parses a standard email header string
const result = addressparser('"John Doe" <john@example.com>, jane@example.com');
// Output: [{ name: 'John Doe', address: 'john@example.com' }, { address: 'jane@example.com' }]

parse-address is built for physical mailing addresses.

  • It handles formats like 123 Main St, City, ST 12345.
  • It splits strings into street, city, state, and zip components.
  • Essential for e-commerce checkout, shipping, and user profiles.
// parse-address: Physical address parsing
const parse = require('parse-address');

// Parses a physical street address string
const result = parse('123 Main St, New York, NY 10001');
// Output: { number: '123', street: 'Main St', city: 'New York', state: 'NY', zip: '10001' }

📦 Input and Output Structure

The shape of data you expect dictates which tool fits.

  • Use addressparser when input is RFC2822 compliant (email headers) and output needs name + email pairs.
  • Use parse-address when input is free-text street addresses and output needs geographic components.

💡 Tip: If you try to parse 123 Main St with addressparser, it will fail or return garbage. If you try to parse Name <email> with parse-address, it will not extract the email correctly.

📜 Compliance and Standards

addressparser follows RFC2822 standards strictly.

  • Handles quoted names, escaped characters, and groups.
  • Reliable for interoperability with other mail systems.
// addressparser: Handles RFC2822 groups
const result = addressparser('Group Name: john@example.com, jane@example.com;');
// Output: [{ name: 'Group Name', address: 'john@example.com' }, ...]

parse-address uses heuristic regex patterns.

  • Works well for common US formats.
  • May struggle with international addresses or complex formatting.
// parse-address: Heuristic parsing
const result = parse('456 Oak Avenue, Suite 100, Los Angeles, CA 90001');
// Output: { street: 'Oak Avenue', suite: '100', city: 'Los Angeles', state: 'CA', zip: '90001' }

🛠️ Maintenance and Ecosystem

addressparser is part of the nodemailer ecosystem.

  • Actively maintained and widely tested.
  • Safe for production email handling.
// addressparser: Used in nodemailer internally
// High reliability for email features

parse-address is a standalone utility.

  • Less actively maintained in recent years.
  • Verify accuracy for your specific use case before relying on it.
// parse-address: Standalone library
// Check recent issues before adopting for critical shipping logic

🌱 When Not to Use These

These utilities are specialized, so consider alternatives when:

  • You need international physical address support: parse-address is US-centric. Look for libraries like libaddressinput.
  • You need email validation: Parsing is not validation. Use validator.js alongside addressparser.
  • Your logic is simple enough for basic string splitting — don't add deps unnecessarily.

📌 Summary Table

Featureaddressparserparse-address
Domain📧 Email Headers (RFC2822)🏠 Physical Mailing Addresses
InputName <email>123 Main St, City, Zip
Output[{ name, address }]{ street, city, state, zip }
Standards✅ RFC2822 Compliant⚠️ Heuristic/Regex Based
Maintenance🟢 Active (Nodemailer)🟡 Less Active
Best ForEmail Clients, SMTP, NotificationsCheckout, Shipping, Profiles

💡 Final Recommendation

Think in terms of data type:

  • Parsing email headers? → Use addressparser. It is the standard for Node.js email handling.
  • Parsing street addresses? → Use parse-address, but test thoroughly for your region.

Critical Warning: Do not mix these up. Using parse-address for email headers will break your mail functionality. Using addressparser for shipping forms will yield useless data. Choose based on the domain of your address data.

How to Choose: addressparser vs parse-address

  • addressparser:

    Choose addressparser if you are working with email headers, SMTP data, or any RFC2822 compliant address lists. It is the robust choice for handling multiple addresses, groups, and named entities in email contexts. This package is actively maintained as part of the nodemailer ecosystem, ensuring long-term stability for mail-related features.

  • parse-address:

    Choose parse-address if you need to split physical mailing addresses entered by users into structured fields like street, city, and zip code. It is suitable for checkout forms, shipping calculators, or user profile updates where physical location data is required. Be aware that this package is less actively maintained than addressparser, so verify its accuracy for your specific region's address formats.

README for addressparser

addressparser

Parse e-mail address fields. Input can be a single address ("andris@kreata.ee"), a formatted address ("Andris Reinman <andris@kreata.ee>"), comma separated list of addresses ("andris@kreata.ee, andris.reinman@kreata.ee"), an address group ("disclosed-recipients:andris@kreata.ee;") or a mix of all the formats.

In addition to comma the semicolon is treated as the list delimiter as well (except when used in the group syntax), so a value "andris@kreata.ee; andris.reinman@kreata.ee" is identical to "andris@kreata.ee, andris.reinman@kreata.ee".

Installation

Install with npm

npm install addressparser

Usage

Include the module

var addressparser = require('addressparser');

Parse some address strings with addressparser(field)

var addresses = addressparser('andris <andris@tr.ee>');
console.log(addresses); // [{name: "andris", address:"andris@tr.ee"}]

And when using groups

addressparser('Composers:"Bach, Sebastian" <sebu@example.com>, mozart@example.com (Mozzie);');

the result would be

[
    {
        name: "Composers",
        group: [
            {
                address: "sebu@example.com",
                name: "Bach, Sebastian"
            },
            {
                address: "mozart@example.com",
                name: "Mozzie"
            }
        ]
    }
]

Be prepared though that groups might be nested.

Notes

This module does not decode any mime-word or punycode encoded strings, it is only a basic parser for parsing the base data, you need to decode the encoded parts later by yourself

License

MIT