ISO 3166-1 gives every country and territory on its list three codes. The United States is US, USA and 840. Ireland is IE, IRL and 372. All three name the same place; they are different spellings of one country code, chosen for different jobs.
The standard currently lists 249 countries and territories. Each one has all three codes, so a dataset can switch between them without losing anything — as long as it knows which one it is holding.
The three codes side by side
| Country | Alpha-2 | Alpha-3 | Numeric |
|---|---|---|---|
| Argentina | AR | ARG | 032 |
| Austria | AT | AUT | 040 |
| Czechia | CZ | CZE | 203 |
| Germany | DE | DEU | 276 |
| Ireland | IE | IRL | 372 |
| Netherlands | NL | NLD | 528 |
| Norway | NO | NOR | 578 |
| United Kingdom | GB | GBR | 826 |
| United States | US | USA | 840 |
These rows come from the shared Country value set, which lists every value's codes together. A dataset column that holds any one of them can be matched to the same country.
Alpha-2: two letters, the everyday key
Alpha-2 codes are two uppercase letters. They are the most common choice for keys, APIs, locale tags such as en-IE, and most internet country domains. Use alpha-2 when you need one compact identifier and have no reason to pick another.
Two quirks catch people early. The United Kingdom's code is GB, not UK; UK is only exceptionally reserved for it, and the .uk domain is a historical exception. And alpha-2 codes are not always the initials you would guess: Germany is DE (Deutschland), Spain is ES (España), Switzerland is CH (Confoederatio Helvetica).
Alpha-3: three letters, easier to read
Alpha-3 codes are three letters: USA, DEU, CHE. They are more recognisable to people, which is why they appear in reports, statistics tables and on machine-readable passports. When someone asks for "3 character country codes" or "3 letter country codes", alpha-3 is usually what they mean.
Alpha-3 is not the same as the sports codes you see on scoreboards. The Olympics write Germany as GER, Switzerland as SUI and the Netherlands as NED; ISO 3166 says DEU, CHE and NLD. A column of IOC or FIFA codes needs its own mapping. The registry's ISO alpha-3 code attribute is bound to exactly the ISO set, which is what makes it safe to join on.
Numeric: three digits that outlast a name
Numeric codes are three digits, taken from the United Nations M49 list: 840, 372, 032. They do not depend on any alphabet, so they suit systems that cannot assume Latin letters.
Numeric codes are also three characters, which is the second answer to "3 character country codes". Store them as text. A column typed as an integer turns Argentina's 032 into 32 and Austria's 040 into 40; the join that follows quietly misses them.
A numeric code changes when the territory changes, even if the letters do not. When South Sudan became independent in 2011, Sudan kept SD and SDN but its numeric code moved from 736 to 729. A time series keyed by numeric code notices the border change; one keyed by letters does not.
Codes change and get reused
ISO 3166 is a living list. Codes are withdrawn, and occasionally a withdrawn code comes back for another place. CS was Czechoslovakia until 1993 and was later assigned to Serbia and Montenegro (2003–2006). ISO 3166-3 keeps four-letter codes for former names, such as CSHH for Czechoslovakia, so historical records can still say what they meant.
For a historical dataset, check that a code meant then what it means now. A present-day lookup table is not a time machine.
Some codes look official but are not. EU is exceptionally reserved for the European Union, which is not a country. XK is a user-assigned code that several organisations use for Kosovo; ISO 3166-1 itself does not assign it. Treat both as deliberate, documented exceptions rather than ordinary values.
Codes are not aliases
A country code comes from the standard. An alias is a name some dataset happens to use. "USA", "United States of America" and "America" are aliases a data source might write in a country column; the shared value set records them so those spellings can be matched to United States.
The Countries reference graph keeps the two apart. Each country is keyed by its alpha-2 code, its alpha-3 code is an attribute, and a separate country alias table maps other datasets' spellings — "Czech Republic" for Czechia, for example — to that country. An alias is an explicit mapping, not a guess: an unrecognised spelling should be reviewed, not matched to the nearest name.
Notice that "USA" can be both: the alpha-3 code and a common alias. That overlap is harmless only when you know which column you are reading. A name column that says "USA" goes through aliases; a code column that says "USA" is looked up as alpha-3.
Traps that break a join
- **Namibia is
NA.** Many CSV readers treatNAas a missing value by default, so Namibia disappears from the data. Turn that default off for code columns. - **Norway is
NO.** Some YAML parsers read an unquotedNOas the boolean false. Quote codes in configuration files. - Leading zeroes. Keep numeric codes as text, as above.
- Not every code is ISO. GeoNames' country table carries a
fipscolumn next toisoandiso3. FIPS 10-4 codes look similar but differ: Germany isGMin FIPS andDEin ISO. - A currency code is not a country code. ISO 4217 writes the US dollar as
USD. It belongs in a currency column, however close it looks toUS.
Which code should you store?
Store alpha-2 as the key unless a system you must integrate with insists on something else. Keep alpha-3 or numeric beside it when people read the data or when you need a code that tracks border changes. Whatever you choose, label the column with the code system it holds — "country" alone does not say whether USA is a code or a name.
The country guide explains why the country itself is one shared identity behind its names, aliases and codes. The billing-country guide shows the same country value playing different roles in one dataset.