Street address parser for Node.js with normalization and secondary unit detection. Current stable version 1.1.20 (last released 2023). Parses US addresses into components (street number, name, suffix, direction, city, state, zip+4). Handles extra whitespace, trailing directionals, PO boxes, and secondary units without delimiters. Normalizes to Title Case and standardizes street suffixes. Includes utility functions for random city generation and city lookup. Ships TypeScript types. Limited to US addresses; no geocoding or validation against real addresses.
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
addresser
✓ import addresser from 'addresser'
✗ const addresser = require('addresser')
Package exports a default object with methods: parseAddress, randomCity, cities. TypeScript types are included; use default import.
parseAddress
✓ import addresser from 'addresser'; addresser.parseAddress(...)
✗ import { parseAddress } from 'addresser'
parseAddress is a method on the default export, not a named export.
randomCity
✓ import addresser from 'addresser'; addresser.randomCity()
✗ const { randomCity } = require('addresser')
randomCity is a method on the default export. CommonJS destructuring won't work because the library uses module.exports = {...}.
Parses a US address into components, demonstrates secondary unit handling, and shows random city generation.
import addresser from 'addresser';
// Parse a full US address
const result = addresser.parseAddress('400 South Orange Ave, South Orange, NJ 07079');
console.log(result.formattedAddress); // '400 South Orange Ave, South Orange, NJ 07079'
console.log(result.streetNumber); // '400'
console.log(result.streetName); // 'South Orange'
console.log(result.streetSuffix); // 'Ave'
console.log(result.placeName); // 'South Orange'
console.log(result.stateAbbreviation);// 'NJ'
console.log(result.zipCode); // '07079'
// Handle secondary units
const unitResult = addresser.parseAddress('1301 Columbia College Drive Unit 101 Columbia, SC 29203');
console.log(unitResult.addressLine2); // 'Unit 101'
// Get a random city
const city = addresser.randomCity();
console.log(city.city); // e.g., 'Irwin'
console.log(city.state); // e.g., 'ID'
Errors
Common errors & fixes
Cannot find module 'addresser'
Package not installed or is installed in a different location.
fixRun 'npm install addresser' in your project root, or ensure it is listed in package.json dependencies.
addresser.parseAddress is not a function
Importing incorrectly: using named import instead of default import.
fixUse 'import addresser from 'addresser'' or 'const addresser = require('addresser')' in CommonJS. TypeError: addresser.randomCity is not a function
Destructuring randomCity from the module incorrectly (e.g., const { randomCity } = require('addresser')).
fixImport the whole module and call addresser.randomCity(): 'const addresser = require('addresser'); addresser.randomCity()'. Audit
Dependencies
No dependency data recorded yet.