Country data utilities — names, emoji flags, continents, and EU membership. Full ISO 3166-1 alpha-2 coverage (249 countries and territories).
Zero dependencies. Works in Node.js, Cloudflare Workers, Deno, Bun, and browsers.
npm install @arraypress/countriesimport { getName, getFlag, format, isValid, getContinent, isEU, getAll } from '@arraypress/countries';
// Look up names
getName('US') // 'United States'
getName('GB') // 'United Kingdom'
// Emoji flags
getFlag('US') // '🇺🇸'
getFlag('JP') // '🇯🇵'
// Formatted display
format('US', { flag: true }) // '🇺🇸 United States'
format('US', { flag: true, code: true }) // '🇺🇸 United States (US)'
// Validation
isValid('US') // true
isValid('XX') // false
// Continents
getContinent('US') // 'North America'
getContinent('JP') // 'Asia'
getContinent('NG') // 'Africa'
// EU membership
isEU('DE') // true
isEU('GB') // false (post-Brexit)
// All countries (for select dropdowns)
getAll() // [{ code: 'AF', name: 'Afghanistan' }, ...]Returns the country name for an ISO code. Returns the code itself if not found. Case-insensitive.
Returns the emoji flag using Unicode regional indicator symbols. Returns empty string for invalid codes.
Format a country for display. Options control whether to include the emoji flag and/or the ISO code in parentheses.
Check if an ISO code exists in the dataset.
Returns the continent: 'Africa', 'Asia', 'Europe', 'North America', 'South America', 'Oceania', or 'Antarctica'.
Check if a country is a current EU member state (27 members post-Brexit).
Returns all 249 countries as [{ code, name }]. Useful for populating select dropdowns.
Full type definitions included.
import { getName, getAll, isEU } from '@arraypress/countries';
import type { Country, FormatOptions } from '@arraypress/countries';MIT