Tiny (~1.6KB), zero-dependency, universal localized address formatter for postal addresses. Version 1.2.0 uses Google's libaddressinput metadata to correctly sort and format address components for over 200 countries/regions. Features ESM and CJS support, TypeScript types included, and output as array or string. Differentiators: minimal bundle size, no dependencies compared to alternatives like localized-address-format, and coverage of all countries via Google's data. Stable and actively maintained.
npm install tinyaddressNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of formatAddress to format a US address (array output) and a UK address (string output) with the country field.
Add 'country' property to the address object if you want the country name displayed.
Use addressLines for lines that should appear between recipient and locality; rely on format for country-specific ordering.
Check country support; for most countries, 'local' and 'latin' produce identical output.
Call .replace(/\n/g, '\r\n') on the result if targeting Windows files.
Add a countryCode field, e.g., countryCode: 'US'.
Ensure the first argument is an object with required properties.
Use a valid ISO 3166-1 alpha-2 country code.
No dependency data recorded yet.