node-country-to-iso
A Node.js library for converting country names, alternative spellings, and informal abbreviations into standardized ISO 3166-1 country codes.
github.com/nojacko/node-country-to-iso is an open-source Node.js utility library designed to convert inconsistent country names, alternative spellings, and informal abbreviations into standardized ISO 3166-1 alpha-2 or alpha-3 country codes. Built to handle messy user inputs and dataset normalization, it parses common variations like “USA”, “U.S.A.”, “US of A”, and native country names into clean ISO representations.
Key Features
- Fuzzy & Variant Name Matching: Normalizes non-standard inputs—including abbreviations, punctuated strings, and regional variants—into canonical ISO country codes.
- Alpha-2 & Alpha-3 Support: Includes dedicated helper functions (
countryToAlpha2andcountryToAlpha3) to output either two-letter or three-letter ISO formats. - Lightweight & High Performance: Fast lookup execution with zero heavy runtime dependencies, optimized for server-side processing or pipeline transformations.
- Dual ESM & CommonJS Compatibility: Built to work seamlessly across modern ES modules, TypeScript, and standard CommonJS Node.js environments.
- Data Cleaning Utility: Ideal for legacy database records, and third-party API payloads.