keecode logokeecode
International
country codes
iso 3166
alpha 2 country codes
alpha 3 country codes
country code list
international codes

ISO 3166 Country Codes Reference - Complete List

Complete reference for ISO 3166 country codes including alpha-2, alpha-3, and numeric codes. Essential for international development, APIs, and forms.

β€’Updated January 15, 2025

ISO 3166 country codes are standardized codes used to represent countries and territories worldwide. This comprehensive guide covers alpha-2, alpha-3, and numeric codes essential for international web development, APIs, and e-commerce.

Table of Contents

  1. What Are ISO 3166 Country Codes?
  2. Types of Country Codes
  3. Most Common Country Codes
  4. Using Country Codes in Development
  5. Country Codes for APIs
  6. Complete Country List
  7. Best Practices

What Are ISO 3166 Country Codes?

ISO 3166 is an international standard for country codes maintained by the International Organization for Standardization (ISO). These codes are used worldwide for:

  • E-commerce: Shipping addresses, tax calculations
  • APIs: Location data, payment processing
  • Forms: Country selection dropdowns
  • Databases: Storing nationality, location
  • Analytics: Geographic reporting
  • Localization: Language and region settings

Types of Country Codes

ISO 3166 provides three different code formats for each country:

Alpha-2 Codes (2-Letter)

Format: Two uppercase letters
Example: US, GB, CA

Most commonly used for:

  • Top-level domains (.us, .uk, .ca)
  • Language tags (en-US, en-GB)
  • Currency codes prefix
  • Most APIs and databases
// Most common usage
const country = 'US';  // United States
const locale = 'en-US';  // English (United States)
const domain = 'example.us';

Alpha-3 Codes (3-Letter)

Format: Three uppercase letters
Example: USA, GBR, CAN

Most commonly used for:

  • Vehicle registration plates
  • Currency codes (ISO 4217)
  • International shipping
  • Some government systems
// Alpha-3 usage
const country = 'USA';  // United States
const currencyCode = 'USD';  // Starts with country alpha-3

Numeric Codes (3-Digit)

Format: Three digits (with leading zeros)
Example: 840, 826, 124

Most commonly used for:

  • Systems that don't support Latin characters
  • UN statistics
  • International databases
  • Some payment systems
// Numeric usage
const country = '840';  // United States
const countryCode = 840;  // As integer
formatexamplelengthusage
Alpha-2US2 lettersMost common
Alpha-3USA3 lettersCurrency codes
Numeric8403 digitsUN systems

Most Common Country Codes

Top 20 Countries by Population

CountryAlpha-2Alpha-3NumericPopulation Rank
ChinaCNCHN1561
IndiaININD3562
United StatesUSUSA8403
IndonesiaIDIDN3604
PakistanPKPAK5865
BrazilBRBRA0766
NigeriaNGNGA5667
BangladeshBDBGD0508
RussiaRURUS6439
MexicoMXMEX48410
JapanJPJPN39211
PhilippinesPHPHL60812
EgyptEGEGY81813
EthiopiaETETH23114
VietnamVNVNM70415
Congo (DRC)CDCOD18016
TurkeyTRTUR79217
IranIRIRN36418
GermanyDEDEU27619
ThailandTHTHA76420

View United States (US) | View China (CN) | View India (IN)

Major English-Speaking Countries

CountryAlpha-2Alpha-3Numeric
United StatesUSUSA840
United KingdomGBGBR826
CanadaCACAN124
AustraliaAUAUS036
New ZealandNZNZL554
IrelandIEIRL372
South AfricaZAZAF710

European Union Countries

CountryAlpha-2Alpha-3Numeric
GermanyDEDEU276
FranceFRFRA250
ItalyITITA380
SpainESESP724
PolandPLPOL616
NetherlandsNLNLD528
BelgiumBEBEL056
SwedenSESWE752
AustriaATAUT040
GreeceGRGRC300

Using Country Codes in Development

HTML Country Select Dropdown

<select name="country" id="country">
  <option value="">Select a country...</option>
  <option value="US">United States</option>
  <option value="GB">United Kingdom</option>
  <option value="CA">Canada</option>
  <option value="AU">Australia</option>
  <option value="DE">Germany</option>
  <option value="FR">France</option>
  <option value="JP">Japan</option>
  <option value="CN">China</option>
  <!-- ... more countries -->
</select>

JavaScript Country Data Structure

const countries = [
  {
    name: 'United States',
    alpha2: 'US',
    alpha3: 'USA',
    numeric: '840',
    currency: 'USD',
    languages: ['en'],
    flag: 'πŸ‡ΊπŸ‡Έ'
  },
  {
    name: 'United Kingdom',
    alpha2: 'GB',
    alpha3: 'GBR',
    numeric: '826',
    currency: 'GBP',
    languages: ['en'],
    flag: 'πŸ‡¬πŸ‡§'
  },
  {
    name: 'Germany',
    alpha2: 'DE',
    alpha3: 'DEU',
    numeric: '276',
    currency: 'EUR',
    languages: ['de'],
    flag: 'πŸ‡©πŸ‡ͺ'
  }
  // ... more countries
];

// Usage
function getCountryByCode(alpha2Code) {
  return countries.find(c => c.alpha2 === alpha2Code);
}

const country = getCountryByCode('US');
console.log(country.name);  // "United States"
console.log(country.currency);  // "USD"

TypeScript Interface

interface Country {
  name: string;
  alpha2: string;
  alpha3: string;
  numeric: string;
  currency: string;
  languages: string[];
  flag: string;
  continent?: string;
  region?: string;
}

const country: Country = {
  name: 'United States',
  alpha2: 'US',
  alpha3: 'USA',
  numeric: '840',
  currency: 'USD',
  languages: ['en'],
  flag: 'πŸ‡ΊπŸ‡Έ',
  continent: 'North America',
  region: 'Americas'
};

React Country Selector Component

import { useState } from 'react';

const countries = [
  { code: 'US', name: 'United States', flag: 'πŸ‡ΊπŸ‡Έ' },
  { code: 'GB', name: 'United Kingdom', flag: 'πŸ‡¬πŸ‡§' },
  { code: 'CA', name: 'Canada', flag: 'πŸ‡¨πŸ‡¦' },
  // ... more countries
];

function CountrySelector({ value, onChange }) {
  return (
    <select 
      value={value} 
      onChange={(e) => onChange(e.target.value)}
      className="country-selector"
    >
      <option value="">Select a country...</option>
      {countries.map(country => (
        <option key={country.code} value={country.code}>
          {country.flag} {country.name}
        </option>
      ))}
    </select>
  );
}

// Usage
function ShippingForm() {
  const [country, setCountry] = useState('');
  
  return (
    <div>
      <label>Country:</label>
      <CountrySelector value={country} onChange={setCountry} />
      {country && <p>Selected: {country}</p>}
    </div>
  );
}

Searchable Country Dropdown

function createSearchableCountryDropdown(countries, inputId, listId) {
  const input = document.getElementById(inputId);
  const list = document.getElementById(listId);
  
  input.addEventListener('input', (e) => {
    const searchTerm = e.target.value.toLowerCase();
    const filtered = countries.filter(country => 
      country.name.toLowerCase().includes(searchTerm) ||
      country.alpha2.toLowerCase().includes(searchTerm)
    );
    
    list.innerHTML = filtered
      .map(country => \`
        <div class="country-option" data-code="\${country.alpha2}">
          <span class="flag">\${country.flag}</span>
          <span class="name">\${country.name}</span>
          <span class="code">\${country.alpha2}</span>
        </div>
      \`)
      .join('');
  });
  
  list.addEventListener('click', (e) => {
    const option = e.target.closest('.country-option');
    if (option) {
      const code = option.dataset.code;
      input.value = option.querySelector('.name').textContent;
      input.dataset.countryCode = code;
      list.style.display = 'none';
    }
  });
}

Country Codes for APIs

REST API Examples

// Get user location by country code
GET /api/users?country=US

// Filter products by country
GET /api/products?shipping_country=GB

// Get country information
GET /api/countries/US

// Response
{
  "alpha2": "US",
  "alpha3": "USA",
  "numeric": "840",
  "name": "United States",
  "currency": "USD",
  "languages": ["en"],
  "region": "Americas"
}

Payment Processing

// Stripe payment intent with country
const paymentIntent = await stripe.paymentIntents.create({
  amount: 1000,
  currency: 'usd',
  payment_method_types: ['card'],
  shipping: {
    name: 'John Doe',
    address: {
      line1: '123 Main St',
      city: 'New York',
      state: 'NY',
      postal_code: '10001',
      country: 'US'  // ISO 3166 alpha-2 code
    }
  }
});

// PayPal
{
  "payer": {
    "address": {
      "country_code": "US"  // ISO 3166 alpha-2 code
    }
  }
}

Shipping APIs

// FedEx, UPS, DHL typically use alpha-2 codes
const shipment = {
  origin: {
    country: 'US',
    city: 'New York',
    zip: '10001'
  },
  destination: {
    country: 'GB',
    city: 'London',
    zip: 'SW1A 1AA'
  }
};

// Calculate shipping rates
fetch('/api/shipping/rates', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(shipment)
});

Geolocation APIs

// IP Geolocation
const response = await fetch('https://ipapi.co/json/');
const data = await response.json();
console.log(data.country_code);  // "US"
console.log(data.country_name);  // "United States"

// Google Maps Geocoding API
{
  "address_components": [
    {
      "long_name": "United States",
      "short_name": "US",  // ISO 3166-1 alpha-2
      "types": ["country", "political"]
    }
  ]
}

Complete Country List

A-D

CountryAlpha-2Alpha-3Numeric
AfghanistanAFAFG004
AlbaniaALALB008
AlgeriaDZDZA012
AndorraADAND020
AngolaAOAGO024
ArgentinaARARG032
ArmeniaAMARM051
AustraliaAUAUS036
AustriaATAUT040
AzerbaijanAZAZE031
BahamasBSBHS044
BahrainBHBHR048
BangladeshBDBGD050
BarbadosBBBRB052
BelarusBYBLR112
BelgiumBEBEL056
BelizeBZBLZ084
BeninBJBEN204
BhutanBTBTN064
BoliviaBOBOL068
Bosnia and HerzegovinaBABIH070
BotswanaBWBWA072
BrazilBRBRA076
BruneiBNBRN096
BulgariaBGBGR100
Burkina FasoBFBFA854
BurundiBIBDI108
CambodiaKHKHM116
CameroonCMCMR120
CanadaCACAN124
Cape VerdeCVCPV132
Central African RepublicCFCAF140
ChadTDTCD148
ChileCLCHL152
ChinaCNCHN156
ColombiaCOCOL170
ComorosKMCOM174
CongoCGCOG178
Costa RicaCRCRI188
CroatiaHRHRV191
CubaCUCUB192
CyprusCYCYP196
Czech RepublicCZCZE203
DenmarkDKDNK208
DjiboutiDJDJI262
DominicaDMDMA212
Dominican RepublicDODOM214

View full list β†’

E-I

CountryAlpha-2Alpha-3Numeric
EcuadorECECU218
EgyptEGEGY818
El SalvadorSVSLV222
EstoniaEEEST233
EthiopiaETETH231
FijiFJFJI242
FinlandFIFIN246
FranceFRFRA250
GabonGAGAB266
GambiaGMGMB270
GeorgiaGEGEO268
GermanyDEDEU276
GhanaGHGHA288
GreeceGRGRC300
GuatemalaGTGTM320
GuineaGNGIN324
HaitiHTHTI332
HondurasHNHND340
HungaryHUHUN348
IcelandISISL352
IndiaININD356
IndonesiaIDIDN360
IranIRIRN364
IraqIQIRQ368
IrelandIEIRL372
IsraelILISR376
ItalyITITA380

J-P

CountryAlpha-2Alpha-3Numeric
JamaicaJMJAM388
JapanJPJPN392
JordanJOJOR400
KazakhstanKZKAZ398
KenyaKEKEN404
KuwaitKWKWT414
KyrgyzstanKGKGZ417
LaosLALAO418
LatviaLVLVA428
LebanonLBLBN422
LibyaLYLBY434
LithuaniaLTLTU440
LuxembourgLULUX442
MalaysiaMYMYS458
MexicoMXMEX484
MoroccoMAMAR504
NetherlandsNLNLD528
New ZealandNZNZL554
NigeriaNGNGA566
NorwayNONOR578
PakistanPKPAK586
PanamaPAPAN591
PeruPEPER604
PhilippinesPHPHL608
PolandPLPOL616
PortugalPTPRT620

Q-Z

CountryAlpha-2Alpha-3Numeric
QatarQAQAT634
RomaniaROROU642
RussiaRURUS643
Saudi ArabiaSASAU682
SerbiaRSSRB688
SingaporeSGSGP702
SlovakiaSKSVK703
SloveniaSISVN705
South AfricaZAZAF710
South KoreaKRKOR410
SpainESESP724
Sri LankaLKLKA144
SwedenSESWE752
SwitzerlandCHCHE756
TaiwanTWTWN158
ThailandTHTHA764
TurkeyTRTUR792
UkraineUAUKR804
United Arab EmiratesAEARE784
United KingdomGBGBR826
United StatesUSUSA840
UruguayUYURY858
VenezuelaVEVEN862
VietnamVNVNM704
ZimbabweZWZWE716

Best Practices

1. Always Use Alpha-2 Codes

// βœ… Good - Use alpha-2 (most standard)
const country = 'US';
const locale = 'en-US';

// ❌ Avoid - Using full names
const country = 'United States';  // Ambiguous, translation issues

// ❌ Avoid - Using numeric codes
const country = 840;  // Less readable, harder to maintain

2. Validate Country Codes

const validCountryCodes = new Set([
  'US', 'GB', 'CA', 'AU', 'DE', 'FR', 'JP', // ... all valid codes
]);

function isValidCountryCode(code) {
  return validCountryCodes.has(code.toUpperCase());
}

// Usage
if (!isValidCountryCode(userInput)) {
  throw new Error('Invalid country code');
}

3. Store Codes, Display Names

// βœ… Good - Store code in database
{
  "user_id": 123,
  "country": "US",  // Store code
  "created_at": "2025-01-15"
}

// Display full name in UI
const countryNames = {
  'US': 'United States',
  'GB': 'United Kingdom',
  'CA': 'Canada'
};

function displayCountry(code) {
  return countryNames[code] || code;
}

4. Handle Special Cases

// UK vs GB
function normalizeCountryCode(code) {
  const normalized = code.toUpperCase();
  
  // Handle common variations
  if (normalized === 'UK') return 'GB';  // UK β†’ GB
  if (normalized === 'USA') return 'US';  // USA β†’ US (if expecting alpha-2)
  
  return normalized;
}

// Usage
const country = normalizeCountryCode('UK');  // Returns 'GB'

5. Consider User Location

// Auto-detect user's country
async function detectUserCountry() {
  try {
    const response = await fetch('https://ipapi.co/json/');
    const data = await response.json();
    return data.country_code;  // e.g., 'US'
  } catch (error) {
    return 'US';  // Default fallback
  }
}

// Pre-select in form
const userCountry = await detectUserCountry();
document.getElementById('country').value = userCountry;

6. Localization

// Display country names in user's language
const countryNames = {
  en: {
    'US': 'United States',
    'FR': 'France',
    'DE': 'Germany'
  },
  es: {
    'US': 'Estados Unidos',
    'FR': 'Francia',
    'DE': 'Alemania'
  },
  fr: {
    'US': 'Γ‰tats-Unis',
    'FR': 'France',
    'DE': 'Allemagne'
  }
};

function getCountryName(code, language = 'en') {
  return countryNames[language]?.[code] || code;
}

console.log(getCountryName('US', 'es'));  // "Estados Unidos"

Common Issues and Solutions

Issue 1: UK vs GB

// Always normalize
function getOfficialCode(code) {
  return code === 'UK' ? 'GB' : code;
}

Issue 2: Country Name Changes

Countries occasionally change names or codes. Examples:

  • Swaziland β†’ Eswatini (SZ remains the same)
  • Macedonia β†’ North Macedonia (MK remains the same)
  • Burma/Myanmar (both MM used)

Solution: Keep your country list updated and use codes, not names.

Issue 3: Disputed Territories

Some territories have codes but may not be universally recognized:

  • Taiwan (TW) - Recognized by ISO but politically complex
  • Palestine (PS) - Observer state
  • Kosovo (XK) - Temporary code

Solution: Be aware of your target audience and handle sensitively.

Summary

ISO 3166 country codes are essential for international web development. Always use alpha-2 codes for consistency, validate user input, and keep your country data updated.

Key Takeaways:

βœ… Use alpha-2 codes (US, GB, CA) for most applications
βœ… Store codes in database, display full names in UI
βœ… Always validate country codes against official list
βœ… Use GB for United Kingdom, not UK
βœ… Consider localization for country names
βœ… Auto-detect user's country when possible
βœ… Keep country data updated with ISO changes