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.
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.
addressparser is built strictly for email addresses found in SMTP headers.
Name <email@example.com>.// 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.
123 Main St, City, ST 12345.// 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' }
The shape of data you expect dictates which tool fits.
addressparser when input is RFC2822 compliant (email headers) and output needs name + email pairs.parse-address when input is free-text street addresses and output needs geographic components.💡 Tip: If you try to parse
123 Main Stwithaddressparser, it will fail or return garbage. If you try to parseName <email>withparse-address, it will not extract the email correctly.
addressparser follows RFC2822 standards strictly.
// 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.
// 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' }
addressparser is part of the nodemailer ecosystem.
// addressparser: Used in nodemailer internally
// High reliability for email features
parse-address is a standalone utility.
// parse-address: Standalone library
// Check recent issues before adopting for critical shipping logic
These utilities are specialized, so consider alternatives when:
parse-address is US-centric. Look for libraries like libaddressinput.validator.js alongside addressparser.| Feature | addressparser | parse-address |
|---|---|---|
| Domain | 📧 Email Headers (RFC2822) | 🏠 Physical Mailing Addresses |
| Input | Name <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 For | Email Clients, SMTP, Notifications | Checkout, Shipping, Profiles |
Think in terms of data type:
addressparser. It is the standard for Node.js email handling.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.
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.
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.
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".
Install with npm
npm install addressparser
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.
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
MIT