i18n-iso-countries vs countries-list vs country-code-lookup vs country-data vs iso-3166-1-alpha-2 vs country-list
Country Data Libraries for Frontend Applications
i18n-iso-countriescountries-listcountry-code-lookupcountry-dataiso-3166-1-alpha-2country-listSimilar Packages:

Country Data Libraries for Frontend Applications

These six npm packages all provide country-related data for JavaScript applications, but they serve different needs and offer varying levels of functionality. countries-list and country-data offer comprehensive country information including names, codes, currencies, and translations. i18n-iso-countries focuses on ISO standard country codes with strong internationalization support. country-code-lookup and country-list provide simpler lookup functionality for basic use cases. iso-3166-1-alpha-2 is the most minimal, offering only the ISO alpha-2 country codes. Choosing the right package depends on your specific data requirements, i18n needs, and whether you need comprehensive country information or just code mappings.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
i18n-iso-countries1,608,714888624 kB55a year agoMIT
countries-list525,2291,309274 kB921 days agoMIT
country-code-lookup132,8238760.7 kB64 hours agoMIT
country-data98,013518-359 years agoMIT
iso-3166-1-alpha-245,196151.76 MB22 years agoMIT
country-list028216.9 kB17 months agoMIT

Country Data Libraries: Choosing the Right Package for Your Frontend

When building international applications, you will inevitably need to work with country data β€” whether for dropdown selectors, address forms, validation, or displaying localized content. The npm ecosystem offers several packages for this purpose, but they differ significantly in scope, data quality, and maintenance status. Let's compare six popular options to help you make an informed choice.

πŸ“¦ Data Coverage: What Information Is Included

The most important difference between these packages is how much country information they provide.

countries-list includes comprehensive data: country names, ISO codes (alpha-2 and alpha-3), currency codes, phone codes, and translations in multiple languages.

import { countries, getCountry } from 'countries-list';

// Get all countries
console.log(countries);
// [{ code: 'US', name: 'United States', currency: 'USD', ... }]

// Get specific country
const country = getCountry('US');
console.log(country.name); // 'United States'
console.log(country.currency); // 'USD'
console.log(country.phone); // '1'

country-code-lookup provides basic lookup functionality with names and codes only.

import countryCodeLookup from 'country-code-lookup';

// Lookup by code
const country = countryCodeLookup.byIso('US');
console.log(country.country); // 'United States'

// Lookup by name
const byName = countryCodeLookup.byCountry('United States');
console.log(byName.iso2); // 'US'

country-data offers rich data including flags, currencies, calling codes, and regional information.

import countries from 'country-data';

// Access country data
const us = countries.countries.US;
console.log(us.name); // 'United States'
console.log(us.currencyCode); // 'USD'
console.log(us.callingCodes); // ['1']
console.log(us.flag); // 'πŸ‡ΊπŸ‡Έ'

// Access currencies
const currencies = countries.currencies;
console.log(currencies.USD.name); // 'US Dollar'

country-list provides a minimal list with codes and names only.

import { getCodes, getName, getCode } from 'country-list';

// Get all country codes
const codes = getCodes(); // ['AD', 'AE', 'AF', ...]

// Get name from code
const name = getName('US'); // 'United States'

// Get code from name
const code = getCode('United States'); // 'US'

i18n-iso-countries focuses on ISO standard codes with extensive language support.

import countries from 'i18n-iso-countries';
import en from 'i18n-iso-countries/langs/en.json';

// Register language
countries.registerLocale(en);

// Get country name in specific language
console.log(countries.getName('US', 'en')); // 'United States'

// Get all country names in language
console.log(countries.getNames('en')); // { US: 'United States', ... }

// Get code from name
console.log(countries.getCode('United States', 'en')); // 'US'

iso-3166-1-alpha-2 provides only the ISO alpha-2 codes β€” nothing else.

import alpha2 from 'iso-3166-1-alpha-2';

// Get all codes
const codes = alpha2.getCodes(); // ['AD', 'AE', 'AF', ...]

// Validate a code
const isValid = alpha2.getAlpha2Code('United States'); // 'US'

// Get country name
const name = alpha2.getCountryName('US'); // 'UNITED STATES'

🌍 Internationalization: Multi-Language Support

If your application serves users in multiple languages, i18n support becomes critical.

countries-list has built-in translations for many languages without needing separate locale files.

import { countries } from 'countries-list';

// Access translations directly
const country = countries.find(c => c.code === 'DE');
console.log(country.name); // Default language
console.log(country.native); // Native name
// Translations available in the package data

country-code-lookup has limited or no official multi-language support.

import countryCodeLookup from 'country-code-lookup';

// Returns English names only
const country = countryCodeLookup.byIso('FR');
console.log(country.country); // 'France' (English only)
// No built-in translation mechanism

country-data includes some translations but focuses on English by default.

import countries from 'country-data';

// Primarily English data
const fr = countries.countries.FR;
console.log(fr.name); // 'France'
// Limited translation support compared to i18n-focused packages

country-list does not include built-in translations.

import { getName } from 'country-list';

// English names only
console.log(getName('JP')); // 'Japan'
// You would need to manage translations separately

i18n-iso-countries has the best multi-language support with official locale files for 50+ languages.

import countries from 'i18n-iso-countries';
import en from 'i18n-iso-countries/langs/en.json';
import de from 'i18n-iso-countries/langs/de.json';
import ja from 'i18n-iso-countries/langs/ja.json';

// Register multiple languages
countries.registerLocale(en);
countries.registerLocale(de);
countries.registerLocale(ja);

// Get names in different languages
console.log(countries.getName('DE', 'en')); // 'Germany'
console.log(countries.getName('DE', 'de')); // 'Deutschland'
console.log(countries.getName('DE', 'ja')); // 'ドむツ'

iso-3166-1-alpha-2 provides English names only with no translation support.

import alpha2 from 'iso-3166-1-alpha-2';

// English only, uppercase
console.log(alpha2.getCountryName('BR')); // 'BRAZIL'
// No multi-language support built in

⚠️ Maintenance Status: What You Need to Know

Package maintenance matters for long-term projects. Some packages in this comparison have known issues.

countries-list is actively maintained with regular updates to country data.

// Current API (verified)
import { countries, getCountry } from 'countries-list';
// Active development, TypeScript support available

country-code-lookup shows signs of limited maintenance. Use with caution for new projects.

// API works but check for updates before adopting
import countryCodeLookup from 'country-code-lookup';
// Consider more actively maintained alternatives for critical projects

country-data is stable but updates may be less frequent than newer packages.

// Stable API
import countries from 'country-data';
// Good for projects needing rich data without frequent updates

country-list is simple and stable with minimal maintenance needs.

// Minimal API, unlikely to break
import { getName, getCode } from 'country-list';
// Suitable for simple use cases

i18n-iso-countries is well-maintained with regular locale updates.

// Active maintenance
import countries from 'i18n-iso-countries';
// Best choice for i18n-heavy applications

iso-3166-1-alpha-2 is minimal and stable but limited in scope.

// Stable but limited
import alpha2 from 'iso-3166-1-alpha-2';
// Only use if you truly need just alpha-2 codes

🎯 Real-World Use Cases

Scenario 1: International Checkout Form

You need country dropdowns with localized names, currency display, and phone number formatting.

Best choice: countries-list or i18n-iso-countries

// Using countries-list
import { countries } from 'countries-list';

function CountrySelect({ userLanguage }) {
  return (
    <select>
      {countries.map(country => (
        <option key={country.code} value={country.code}>
          {country.name} ({country.currency})
        </option>
      ))}
    </select>
  );
}

// Using i18n-iso-countries
import countries from 'i18n-iso-countries';
import en from 'i18n-iso-countries/langs/en.json';
countries.registerLocale(en);

function CountrySelect({ locale }) {
  const countryNames = countries.getNames(locale);
  return (
    <select>
      {Object.entries(countryNames).map(([code, name]) => (
        <option key={code} value={code}>{name}</option>
      ))}
    </select>
  );
}

Scenario 2: Address Validation

You need to validate country codes submitted from forms.

Best choice: country-list or iso-3166-1-alpha-2

// Using country-list
import { getCode } from 'country-list';

function validateCountry(input) {
  const code = getCode(input);
  return code !== undefined;
}

// Using iso-3166-1-alpha-2
import alpha2 from 'iso-3166-1-alpha-2';

function validateCountry(input) {
  const code = alpha2.getAlpha2Code(input);
  return code !== null;
}

Scenario 3: Country Profile Pages

You need to display flags, currencies, calling codes, and regional information.

Best choice: country-data

import countries from 'country-data';

function CountryProfile({ countryCode }) {
  const country = countries.countries[countryCode];
  
  return (
    <div>
      <h1>{country.flag} {country.name}</h1>
      <p>Currency: {country.currencyCode}</p>
      <p>Calling Code: +{country.callingCodes[0]}</p>
      <p>Region: {country.region}</p>
    </div>
  );
}

Scenario 4: Simple Country Dropdown

You just need a basic country selector with minimal bundle size.

Best choice: country-list

import { getCodes, getName } from 'country-list';

function SimpleCountrySelect() {
  const codes = getCodes();
  
  return (
    <select>
      {codes.map(code => (
        <option key={code} value={code}>
          {getName(code)}
        </option>
      ))}
    </select>
  );
}

πŸ“Š Feature Comparison Summary

Featurecountries-listcountry-code-lookupcountry-datacountry-listi18n-iso-countriesiso-3166-1-alpha-2
Country Namesβœ…βœ…βœ…βœ…βœ…βœ…
ISO Alpha-2βœ…βœ…βœ…βœ…βœ…βœ…
ISO Alpha-3βœ…βœ…βœ…βŒβœ…βŒ
Currency Codesβœ…βŒβœ…βŒβŒβŒ
Phone Codesβœ…βŒβœ…βŒβŒβŒ
FlagsβŒβŒβœ…βŒβŒβŒ
Multi-Languageβœ…βŒβš οΈ LimitedβŒβœ… Excellent❌
Data RichnessHighLowHighLowMediumMinimal

πŸ’‘ Key Decision Factors

Choose Based on Data Needs

If you need comprehensive country information (currencies, phone codes, regions), go with countries-list or country-data. These packages save you from managing multiple data sources.

If you need just codes and names for simple forms or validation, country-list or iso-3166-1-alpha-2 keep your bundle smaller.

Choose Based on Language Requirements

If your application serves multiple languages, i18n-iso-countries is the clear winner. It has official locale files for 50+ languages and follows ISO standards closely.

countries-list also offers good translation support built into the package data.

Choose Based on Maintenance Concerns

For long-term projects, prefer actively maintained packages. i18n-iso-countries and countries-list show consistent update patterns.

Be cautious with country-code-lookup for critical applications β€” verify current maintenance status before committing.

Choose Based on Standards Compliance

If ISO 3166 compliance matters for your project (enterprise, government, financial), i18n-iso-countries follows the standard most closely.

iso-3166-1-alpha-2 is literally just the standard codes β€” nothing more, nothing less.

🚫 When to Avoid Each Package

Avoid country-code-lookup if you need guaranteed long-term maintenance or comprehensive data. Consider it only for quick prototypes or internal tools.

Avoid iso-3166-1-alpha-2 for most applications β€” it is too minimal unless you specifically need only alpha-2 codes with no other data.

Avoid country-list if you need translations or currency information β€” you will end up adding more packages anyway.

Avoid country-data if bundle size is critical β€” it includes more data than many projects need.

Avoid countries-list if you need extensive language support beyond what is included β€” i18n-iso-countries has better i18n coverage.

Avoid i18n-iso-countries if you need currency, phone codes, or flags β€” it focuses on codes and names only.

🏁 Final Thoughts

There is no single best package β€” the right choice depends on your specific requirements:

  • Need rich data with translations? β†’ countries-list
  • Need best i18n support? β†’ i18n-iso-countries
  • Need flags and regional data? β†’ country-data
  • Need simple validation? β†’ country-list or iso-3166-1-alpha-2
  • Building a quick prototype? β†’ country-code-lookup works but verify maintenance

For most production frontend applications serving international users, i18n-iso-countries or countries-list provide the best balance of features, maintenance, and developer experience. Choose based on whether you prioritize language support (i18n-iso-countries) or comprehensive country data (countries-list).

How to Choose: i18n-iso-countries vs countries-list vs country-code-lookup vs country-data vs iso-3166-1-alpha-2 vs country-list

  • i18n-iso-countries:

    Choose i18n-iso-countries if internationalization is your top priority and you need ISO-standard country codes with translations in many languages. It follows ISO 3166 standards closely and offers the best language support for global applications. This is ideal for enterprise applications serving multiple regions.

  • countries-list:

    Choose countries-list if you need comprehensive country data with built-in translations for multiple languages. It includes country names, codes, currencies, and phone codes in one package. This works well for forms, dropdowns, and international applications where you need localized country names without managing separate translation files.

  • country-code-lookup:

    Choose country-code-lookup if you need simple, fast lookups by country code or name without extra data. It is ideal for validation scenarios where you just need to verify if a country code exists or get a country name from a code. Keep in mind this package appears less actively maintained than alternatives.

  • country-data:

    Choose country-data if you need rich country information including flags, currencies, calling codes, and regional data. It provides more detailed information than simpler packages and works well for applications displaying country profiles or needing currency and phone code information alongside country names.

  • iso-3166-1-alpha-2:

    Choose iso-3166-1-alpha-2 only if you need the absolute minimal package with just ISO alpha-2 codes. It is suitable for very specific use cases where you only need code validation without names or other data. For most applications, one of the more feature-rich packages would be a better choice.

  • country-list:

    Choose country-list if you need a minimal, straightforward list of countries with codes. It is suitable for simple dropdowns or basic validation where you do not need translations, currencies, or other extended data. This package keeps your bundle smaller but offers limited functionality.

README for i18n-iso-countries

i18n-iso-countries

i18n for ISO 3166-1 country codes. We support Alpha-2, Alpha-3 and Numeric codes from 'Wikipedia: Officially assigned code elements'

Installing

Install it using npm: npm install i18n-iso-countries

var countries = require("i18n-iso-countries");

If you use i18n-iso-countries with Node.js, you are done. If you use the package in a browser environment, you have to register the languages you want to use to minimize the file size.

// Support french & english languages.
countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
countries.registerLocale(require("i18n-iso-countries/langs/fr.json"));

Code to Country

Get the name of a country by its ISO 3166-1 Alpha-2, Alpha-3 or Numeric code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("US (Alpha-2) => " + countries.getName("US", "en")); // United States of America
console.log("US (Alpha-2) => " + countries.getName("US", "de")); // Vereinigte Staaten von Amerika
console.log("USA (Alpha-3) => " + countries.getName("USA", "en")); // United States of America
console.log("USA (Numeric) => " + countries.getName("840", "en")); // United States of America

Get aliases/short name using select

// Some countries have alias/short names defined. `select` is used to control which
// name will be returned.
console.log("GB (select: official) => " + countries.getName("GB", "en", {select: "official"})); // United Kingdom
console.log("GB (select: alias) => " + countries.getName("GB", "en", {select: "alias"})); // UK
console.log("GB (select: all) => " + countries.getName("GB", "en", {select: "all"})); // ["United Kingdom", "UK", "Great Britain"]
// Countries without an alias will always return the offical name
console.log("LT (select: official) => " + countries.getName("LT", "en", {select: "official"})); // Lithuania
console.log("LT (select: alias) => " + countries.getName("LT", "en", {select: "alias"})); // Lithuania
console.log("LT (select: all) => " + countries.getName("LT", "en", {select: "all"})); // ["Lithuania"]

Get all names by their ISO 3166-1 Alpha-2 code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getNames("en", {select: "official"})); // { 'AF': 'Afghanistan', 'AL': 'Albania', [...], 'ZM': 'Zambia', 'ZW': 'Zimbabwe' }

Supported languages (ISO 639-1)

In case you want to add new language, please refer ISO 639-1 table.

  • af: Afrikaans
  • am: Amharic
  • ar: Arabic
  • az: Azerbaijani
  • be: Belorussian
  • bg: Bulgarian
  • bn: Bengali
  • br: Breton
  • bs: Bosnian
  • ca: Catalan
  • cs: Czech
  • cy: Cymraeg
  • da: Danish
  • de: German
  • dv: Dhivehi
  • en: English
  • es: Spanish
  • et: Estonian
  • eu: Basque
  • fa: Persian
  • fi: Finnish
  • fr: French
  • ga: Irish
  • gl: Galician
  • el: Greek
  • ha: Hausa
  • he: Hebrew
  • hi: Hindi
  • hr: Croatian
  • hu: Hungarian
  • hy: Armenian
  • is: Icelandic
  • it: Italian
  • id: Indonesian
  • ja: Japanese
  • ka: Georgian
  • kk: Kazakh
  • km: Khmer
  • ko: Korean
  • ku: Kurdish
  • ky: Kyrgyz
  • lt: Lithuanian
  • lv: Latvian
  • mk: Macedonian
  • ml: Malayalam
  • mn: Mongolian
  • mr: Marathi
  • ms: Malay
  • mt: Maltese
  • nb: Norwegian BokmΓ₯l
  • nl: Dutch
  • nn: Norwegian Nynorsk
  • no: Norwegian
  • pl: Polish
  • ps: Pashto
  • pt: Portuguese
  • ro: Romanian
  • ru: Russian
  • sd: Sindhi
  • sk: Slovak
  • sl: Slovene
  • so: Somali
  • sq: Albanian
  • sr: Serbian
  • sv: Swedish
  • sw: Swahili
  • ta: Tamil
  • tg: Tajik
  • th: Thai
  • tk: Turkmen
  • tr: Turkish
  • tt: Tatar
  • ug: Uyghur
  • uk: Ukrainian
  • ur: Urdu
  • uz: Uzbek
  • zh: Chinese
  • vi: Vietnamese

List of ISO 639-1 codes

Get all supported languages (ISO 639-1)

var countries = require("i18n-iso-countries");
console.log("List of supported languages => " + countries.getSupportedLanguages());
// List of supported languages => ["cy", "dv", "sw", "eu", "af", "am", ...]

Country to Code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("United States of America => " + countries.getAlpha2Code("United States of America", "en"));
// United States of America => US

console.log("United States of America => " + countries.getAlpha3Code("United States of America", "en"));
// United States of America => USA

Codes

Convert Alpha-3 to Alpha-2 code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("USA (Alpha-3) => " + countries.alpha3ToAlpha2("USA") + " (Alpha-2)");
// USA (Alpha-3) => US (Alpha-2)

Convert Numeric to Alpha-2 code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("840 (Numeric) => " + countries.numericToAlpha2("840") + " (Alpha-2)");
// 840 (Numeric) => US (Alpha-2)

Convert Alpha-2 to Alpha-3 code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("DE (Alpha-2) => " + countries.alpha2ToAlpha3("DE") + " (Alpha-3)");
// DE (Alpha-2) => DEU (Alpha-3)

Convert Numeric to Alpha-3 code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("840 (Numeric) => " + countries.numericToAlpha3("840") + " (Alpha-3)");
// 840 (Numeric) => USA (Alpha-3)

Convert Alpha-3 to Numeric code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.alpha3ToNumeric("SWE"));
// 752

Convert Alpha-2 to Numeric code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.alpha2ToNumeric("SE"));
// 752

Get all Alpha-2 codes

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getAlpha2Codes());
// { 'AF': 'AFG', 'AX': 'ALA', [...], 'ZM': 'ZMB', 'ZW': 'ZWE' }

Get all Alpha-3 codes

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getAlpha3Codes());
// { 'AFG': 'AF', 'ALA': 'AX', [...], 'ZMB': 'ZM', 'ZWE': 'ZW' }

Get all Numeric codes

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getNumericCodes());
// { '004': 'AF', '008': 'AL', [...], '887': 'YE', '894': 'ZM' }

Validate country code

var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
  countries.isValid("US"),
  countries.isValid("USA"),
  countries.isValid("XX")
);
// true, true, false

Contribution

To add a language:

  • add a json file under langs/
  • add the language to the list in supportedLocales.json at the top
  • add language to section Supported languages in README.md
  • add language to keywords in package.json
  • run npm run lint and npm test
  • open a PR on GitHub

You can check codes here: https://www.iso.org/obp/ui/#home