Alpha-3 vs Alpha-2 Country Codes — When to Use Each

Compare ISO 3166-1 alpha-2 and alpha-3 country codes. Understand the trade-offs and which format to use in APIs, databases, and international trade.

Standards

Detailed Explanation

Alpha-2 vs Alpha-3: A Side-by-Side Comparison

ISO 3166-1 defines two letter-based code sets for countries. Choosing the right one depends on your context.

Comparison Table

Aspect Alpha-2 Alpha-3
Length 2 letters 3 letters
Example US, GB, JP USA, GBR, JPN
Total codes 249 249
Primary use Web, DNS, locale Trade, banking, athletics
Readability Lower Higher (more recognizable)
Storage 2 bytes 3 bytes
Standard ISO 3166-1 ISO 3166-1

When to Use Alpha-2

  • Web development — HTML lang attribute, BCP 47 tags, locale routing
  • Domain names — ccTLDs are based on alpha-2 codes
  • APIs — Most web APIs use alpha-2 for compactness
  • Databases — When storage efficiency matters
  • Postal services — Some systems use alpha-2

When to Use Alpha-3

  • International shipping — Customs declarations and trade documents
  • Banking — SWIFT/BIC codes reference alpha-3 in some contexts
  • Sports — IOC (Olympic) codes are based on alpha-3 (with some differences)
  • UN statistics — Official UN data often uses alpha-3
  • Readability — When a human needs to recognize the country quickly (USA vs US, DEU vs DE)

Key Differences in Specific Countries

Some countries have notably different alpha-2 and alpha-3 codes:

Country Alpha-2 Alpha-3 Why
Germany DE DEU DE from Deutsch, DEU from Deutschland
China CN CHN CN abbreviation, CHN is more readable
North Korea KP PRK KP from Korea People's, PRK from People's Republic of Korea
Switzerland CH CHE CH from Confoederatio Helvetica
Sri Lanka LK LKA LK from Lanka, LKA extended

Conversion Between Formats

Since both alpha-2 and alpha-3 are part of the same ISO 3166-1 standard, there is always a one-to-one mapping. You can convert freely using lookup tables. Many programming libraries provide this:

// Example: using Intl.DisplayNames
const displayNames = new Intl.DisplayNames(['en'], { type: 'region' });
console.log(displayNames.of('US')); // "United States"

Use Case

A logistics company builds an international shipping system that uses alpha-3 codes on customs forms and trade documents, but converts to alpha-2 for the web interface and API endpoints. A lookup table maps between the two formats seamlessly.

Try It — Country Code Reference

Open full tool