These six npm packages provide country-related data for web applications, but they serve different purposes. countries-list, country-list, and country-data offer comprehensive country information including names, codes, currencies, and languages. i18n-iso-countries focuses on ISO standard country code translations across multiple languages. country-code-lookup provides simple code-to-country mapping utilities. iso-3166-1 delivers strict ISO 3166-1 standard compliance. Choosing the right one depends on whether you need full country details, just code translations, or strict standards adherence.
When building international applications, you will need country data for forms, validation, display, or analytics. These six packages all handle country information, but they differ significantly in scope, data structure, and intended use cases. Let's examine how each one works in practice.
The way you access country data varies greatly between these packages. Some return objects, others return arrays, and some provide utility functions.
countries-list exports country data as an object with country codes as keys.
import { countries } from 'countries-list';
// Access by country code
const usa = countries['US'];
console.log(usa.name); // "United States"
console.log(usa.currency); // "USD"
console.log(usa.languages); // ["en"]
// Iterate through all countries
Object.values(countries).forEach(country => {
console.log(country.name);
});
country-code-lookup provides utility functions for code-to-name conversion.
import lookup from 'country-code-lookup';
// Lookup by ISO code
const country = lookup.byIso('US');
console.log(country.country); // "United States"
// Lookup by country name
const byName = lookup.byCountry('United States');
console.log(byName.iso2); // "US"
// Get all countries
const all = lookup.countries;
country-data exports data as arrays with detailed metadata.
import countries from 'country-data';
// Access countries array
const usa = countries.countries.find(c => c.alpha2 === 'US');
console.log(usa.name); // "United States"
console.log(usa.region); // "Americas"
console.log(usa.flag); // "πΊπΈ"
// Access currencies separately
const usd = countries.currencies.USD;
country-list provides a simple array of country objects.
import countries from 'country-list';
// Get all countries as array
const all = countries.getData();
// [{ code: 'US', name: 'United States' }, ...]
// Find by code
const usa = countries.getName('US'); // "United States"
// Get code from name
const code = countries.getCode('United States'); // "US"
i18n-iso-countries focuses on translated country names with ISO compliance.
import countries from 'i18n-iso-countries';
import enLocale from 'i18n-iso-countries/langs/en.json';
// Register locale
countries.registerLocale(enLocale);
// Get name in registered language
const name = countries.getName('US', 'en'); // "United States"
// Get all names in a language
const allNames = countries.getNames('en');
// { US: "United States", GB: "United Kingdom", ... }
// Get code from name
const code = countries.getCode('United States', 'en'); // "US"
iso-3166-1 provides strict ISO standard code mappings.
import { alpha2, alpha3, numeric } from 'iso-3166-1';
// Get country by alpha-2 code
const usa = alpha2.get('US');
console.log(usa.name); // "United States"
console.log(usa.alpha3); // "USA"
console.log(usa.numeric); // "840"
// Get by alpha-3 code
const byAlpha3 = alpha3.get('USA');
// Get all countries
const all = alpha2.all();
Language support is a major differentiator between these packages.
countries-list includes language codes per country but does not translate country names.
import { countries } from 'countries-list';
const france = countries['FR'];
console.log(france.languages); // ["fr"]
console.log(france.name); // "France" (English only)
country-code-lookup provides English names only without translation support.
import lookup from 'country-code-lookup';
const country = lookup.byIso('DE');
console.log(country.country); // "Germany" (English only)
country-data includes English names with some regional metadata but no built-in translations.
import countries from 'country-data';
const japan = countries.countries.find(c => c.alpha2 === 'JP');
console.log(japan.name); // "Japan" (English only)
console.log(japan.region); // "Asia"
country-list supports multiple languages through separate locale packages.
import countries from 'country-list';
import { translate } from 'country-list/translate';
// Default English
const name = countries.getName('ES'); // "Spain"
// With translation (requires additional setup)
translate('ES', 'fr'); // "Espagne"
i18n-iso-countries excels at multi-language support with 100+ locales available.
import countries from 'i18n-iso-countries';
import enLocale from 'i18n-iso-countries/langs/en.json';
import frLocale from 'i18n-iso-countries/langs/fr.json';
import deLocale from 'i18n-iso-countries/langs/de.json';
countries.registerLocale(enLocale);
countries.registerLocale(frLocale);
countries.registerLocale(deLocale);
const nameEn = countries.getName('ES', 'en'); // "Spain"
const nameFr = countries.getName('ES', 'fr'); // "Espagne"
const nameDe = countries.getName('ES', 'de'); // "Spanien"
iso-3166-1 provides standard codes without name translations.
import { alpha2 } from 'iso-3166-1';
const country = alpha2.get('BR');
console.log(country.name); // "Brazil" (English only)
console.log(country.alpha2); // "BR"
console.log(country.alpha3); // "BRA"
Different packages offer different lookup strategies that affect both code clarity and runtime performance.
countries-list uses direct object property access for O(1) lookups.
import { countries } from 'countries-list';
// Direct property access - fastest
const country = countries['CA'];
// Convert to array if needed
const countryArray = Object.values(countries);
country-code-lookup provides multiple lookup methods with internal caching.
import lookup from 'country-code-lookup';
// Multiple lookup strategies
const byIso2 = lookup.byIso('CA');
const byIso3 = lookup.byIso('CAN');
const byName = lookup.byCountry('Canada');
const byCallingCode = lookup.byCallingCode('1');
country-data requires array iteration for lookups.
import countries from 'country-data';
// Array find operation - O(n)
const country = countries.countries.find(c => c.alpha2 === 'CA');
// Direct access for currencies
const currency = countries.currencies.CAD;
country-list provides helper functions for common operations.
import countries from 'country-list';
// Built-in helper methods
const name = countries.getName('CA');
const code = countries.getCode('Canada');
const all = countries.getData();
// Custom filtering
const filtered = countries.getData().filter(c => c.name.startsWith('A'));
i18n-iso-countries requires locale registration before lookups work.
import countries from 'i18n-iso-countries';
import enLocale from 'i18n-iso-countries/langs/en.json';
countries.registerLocale(enLocale);
// Lookups work after registration
const name = countries.getName('CA', 'en');
const code = countries.getCode('Canada', 'en');
const all = countries.getNames('en');
iso-3166-1 separates lookups by code type for type safety.
import { alpha2, alpha3, numeric } from 'iso-3166-1';
// Type-specific lookups
const byAlpha2 = alpha2.get('CA');
const byAlpha3 = alpha3.get('CAN');
const byNumeric = numeric.get('124');
// Get all of a specific type
const allAlpha2 = alpha2.all();
Package maintenance affects long-term project stability.
country-data β This package is deprecated and should not be used in new projects. The maintainer has marked it as archived with no future updates planned. Existing projects should migrate to alternatives like countries-list or i18n-iso-countries.
// β Do not use in new projects
import countries from 'country-data'; // Deprecated
// β
Use instead
import { countries } from 'countries-list';
countries-list, country-code-lookup, country-list, i18n-iso-countries, and iso-3166-1 are all actively maintained with regular updates for ISO standard changes.
For form dropdowns, you need a simple code-name pair list.
// Using countries-list
import { countries } from 'countries-list';
const options = Object.values(countries).map(c => ({
value: c.iso2,
label: c.name
}));
// Using country-list
import countries from 'country-list';
const options = countries.getData().map(c => ({
value: c.code,
label: c.name
}));
// Using i18n-iso-countries (for multi-language)
import countries from 'i18n-iso-countries';
import enLocale from 'i18n-iso-countries/langs/en.json';
countries.registerLocale(enLocale);
const options = Object.entries(countries.getNames('en')).map(([code, name]) => ({
value: code,
label: name
}));
For validating user input against country codes.
// Using country-code-lookup
import lookup from 'country-code-lookup';
function validateCountryCode(code) {
const country = lookup.byIso(code);
return country !== null;
}
// Using iso-3166-1
import { alpha2 } from 'iso-3166-1';
function validateCountryCode(code) {
return alpha2.get(code) !== undefined;
}
// Using countries-list
import { countries } from 'countries-list';
function validateCountryCode(code) {
return code in countries;
}
For showing country names with emoji flags.
// Using country-data (has flag emoji built-in)
import countries from 'country-data';
const usa = countries.countries.find(c => c.alpha2 === 'US');
console.log(`${usa.flag} ${usa.name}`); // πΊπΈ United States
// Using countries-list (no flag, add manually)
import { countries } from 'countries-list';
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
const usa = countries['US'];
console.log(`${getFlagEmoji(usa.iso2)} ${usa.name}`);
For apps supporting multiple user languages.
// Using i18n-iso-countries (best for i18n)
import countries from 'i18n-iso-countries';
import enLocale from 'i18n-iso-countries/langs/en.json';
import esLocale from 'i18n-iso-countries/langs/es.json';
import frLocale from 'i18n-iso-countries/langs/fr.json';
countries.registerLocale(enLocale);
countries.registerLocale(esLocale);
countries.registerLocale(frLocale);
function getCountryName(code, userLanguage) {
return countries.getName(code, userLanguage) || countries.getName(code, 'en');
}
// Usage
const name = getCountryName('DE', 'es'); // "Alemania"
| Feature | countries-list | country-code-lookup | country-data | country-list | i18n-iso-countries | iso-3166-1 |
|---|---|---|---|---|---|---|
| Country Names | β English | β English | β English | β English + locales | β 100+ languages | β English |
| ISO Codes | β Alpha-2, Alpha-3 | β Alpha-2, Alpha-3 | β Alpha-2, Alpha-3 | β Alpha-2 | β Alpha-2, Alpha-3, Numeric | β Alpha-2, Alpha-3, Numeric |
| Currency Data | β Yes | β No | β Yes | β No | β No | β No |
| Language Data | β Country languages | β No | β No | β No | β No | β No |
| Flag Emoji | β No | β No | β Yes | β No | β No | β No |
| Multi-Language | β No | β No | β No | β οΈ Limited | β Excellent | β No |
| Lookup Speed | β‘ O(1) | β‘ O(1) | π O(n) | β‘ O(1) | β‘ O(1) | β‘ O(1) |
| Maintenance | β Active | β Active | β Deprecated | β Active | β Active | β Active |
Choose based on your specific requirements:
Need multi-language support? β i18n-iso-countries is the clear winner with 100+ locales and proper ISO compliance.
Need currency and language data per country? β countries-list provides the most comprehensive metadata without deprecation concerns.
Need simple code-to-name lookup? β country-code-lookup or country-list both work well with minimal overhead.
Need strict ISO standard compliance? β iso-3166-1 provides the most accurate standard code mappings.
Need flag emojis? β country-data has them built-in, but remember it is deprecated. Consider countries-list with manual emoji generation instead.
Building new projects? β Avoid country-data entirely due to deprecation. Choose countries-list for rich data or i18n-iso-countries for internationalization.
These packages solve overlapping but distinct problems. i18n-iso-countries stands out for internationalized applications where users see country names in their language. countries-list works best when you need comprehensive country metadata like currencies and languages. country-code-lookup and country-list serve simple lookup needs with minimal setup. iso-3166-1 fits regulatory or financial contexts requiring strict standard compliance.
The deprecated status of country-data means new projects should evaluate the five remaining options based on their specific data requirements. For most modern frontend applications, countries-list or i18n-iso-countries will cover the majority of use cases with active maintenance and good developer experience.
Choose countries-list if you need comprehensive country data including codes, names, currencies, and languages in a single package. It works well for forms with country selectors, shipping calculators, or any feature requiring detailed country information. The package provides both CommonJS and ES module exports for flexible integration.
Choose country-code-lookup if you need simple, fast lookups from country codes to country names without extra data overhead. It is ideal for validation logic, display formatting, or scenarios where you already have country codes and just need to show human-readable names to users.
Choose country-data if you need extensive country information including flags, regions, and calling codes alongside standard codes and names. This package suits applications requiring rich country metadata for internationalization, analytics dashboards, or geographic filtering features.
Choose country-list if you prefer a minimal, straightforward package that provides basic country code and name mappings. It works well for simple dropdowns, basic validation, or projects where you want to minimize dependencies without needing advanced features.
Choose i18n-iso-countries if your application needs country names translated into multiple languages with ISO standard compliance. It is perfect for internationalized applications, multi-language forms, or any project where users interact with country data in their preferred language.
Choose iso-3166-1 if you need strict adherence to the ISO 3166-1 standard with alpha-2, alpha-3, and numeric codes. It suits regulatory compliance scenarios, financial applications, or any project where standard code accuracy matters more than additional country metadata.
Continents & countries: ISO 3166-1 alpha-2 code (with alpha-2 to alpha-3 set), name, ISO 639-1 languages, capital and ISO 4217 currency codes, native name, calling codes. Lists are available in JSON, CSV and SQL formats. Also, contains separate JSON files with additional country Emoji flags data.
Version 3 comes with some data structure changes. It was completely reworked under the hood with TypeScript, ESM exports and Turborepo file structure.
Everything is strongly typed so you can easily use data with auto-complete in your IDE.
Note: If your projects depend on the old structure, carefully specify required versions in your dependencies.
Package is available via:
bun add countries-listnpm install countries-listcomposer require annexare/countries-listModule exports continents, countries, languages and utility functions.
// Interfaces and types
import type {
ICountry,
ICountryData,
ILanguage,
TContinentCode,
TCountryCode,
TLanguageCode,
} from 'countries-list'
// Main data and utils
import { continents, countries, languages } from 'countries-list'
// Utils
import { getCountryCode, getCountryData, getCountryDataList, getEmojiFlag } from 'countries-list'
// Minimal data in JSON
import countries2to3 from 'countries-list/minimal/countries.2to3.min.json'
import countries3to2 from 'countries-list/minimal/countries.3to2.min.json'
import languageNames from 'countries-list/minimal/languages.native.min'
getCountryCode('Ukraine') // 'UA'
getCountryCode('Π£ΠΊΡΠ°ΡΠ½Π°') // 'UA'
getCountryData('UA') // ICountryData
Built files are in the dist directory of this repository, and packages/countries directory contains source data.
Note: JS build contains ES modules, CommonJS and IIFE (for now)
cjs/index.jsmjs/index.jsindex.iife.jsconst continents = {
AF: 'Africa',
AN: 'Antarctica',
AS: 'Asia',
EU: 'Europe',
NA: 'North America',
OC: 'Oceania',
SA: 'South America',
}
const countries = {
// ...
UA: {
name: 'Ukraine',
native: 'Π£ΠΊΡΠ°ΡΠ½Π°',
phone: [380],
continent: 'EU',
capital: 'Kyiv',
currency: ['UAH'],
languages: ['uk'],
},
// ...
}
const languages = {
// ...
uk: {
name: 'Ukrainian',
native: 'Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ°',
},
ur: {
name: 'Urdu',
native: 'Ψ§Ψ±Ψ―Ω',
rtl: 1,
},
// ...
}
Everything is generated from strongly typed files in packages/countries/src, including SQL file.
Everything in dist is generated,
so please make data related changes ONLY to files from packages/countries, commit them.
Use bun run build (or turbo build, turbo test) command to build/test generated files.
Prepared by Annexare Studio from different public sources. Feel free to use it as you need in your apps or send updates into this public repository. It's under MIT license.