Skip to content
Generate now

ISO Country Codes Explained: Alpha-2, Alpha-3, Numeric

Two letters stand for a country on almost every form you fill in, yet many developers only learn the rules behind them after a bug. Why is Germany DE? Why do some systems want three letters instead of two? And how does a pair of letters turn into a flag emoji? This guide explains the ISO 3166 family of country codes, how they are used in software and the mistakes worth avoiding.

Options

Tip: press Enter or Space to generate again.

Ready

Three codes for every country

The international standard ISO 3166-1 gives each country or territory three codes:

  • Alpha-2 โ€” two letters, the most widely used: US, DE, JP.
  • Alpha-3 โ€” three letters, easier to recognize at a glance: USA, DEU, JPN.
  • Numeric โ€” three digits, independent of any alphabet: 840, 276, 392.

Alpha-2 is the default for web forms, shipping and payments. Alpha-3 appears in some passports and sports results, while numeric codes are handy when letters could cause confusion across writing systems.

Why some codes look strange

Codes are often based on a countryโ€™s own name rather than its English one:

  • DE โ€” Germany, from Deutschland.
  • ES โ€” Spain, from Espaรฑa.
  • CH โ€” Switzerland, from the Latin Confoederatio Helvetica.
  • HR โ€” Croatia, from Hrvatska.
  • ZA โ€” South Africa, from the Dutch Zuid-Afrika.

Codes also change with history. When a country dissolves or renames itself, codes are retired or replaced โ€” Czechoslovakiaโ€™s CS and the Soviet Unionโ€™s SU are no longer active, which is why old databases sometimes contain codes that modern validators reject.

Domains, flags and subdivisions

Country-code internet domains mostly follow alpha-2: .de, .jp, .br. The best-known exception is the United Kingdom, which uses .uk even though its ISO code is GB.

Flag emoji are built from the same codes. Unicode defines 26 โ€œregional indicatorโ€ letters, and a supporting device shows the right flag when two of them appear together, so the letters F and R become the French flag. Some systems show only the letters, which is why flags look different across platforms.

For regions inside a country there is ISO 3166-2, which adds a suffix to the alpha-2 code: US-CA for California or CA-ON for Ontario.

Generate country codes with RandNow

The Random Country Code Generator above is a quick source of realistic values:

  1. Enter a number from 1 to 100 in How many?.
  2. Press Generate. Each result shows the flag, the code and the country name, for example ๐Ÿ‡ท๐Ÿ‡ด RO (Romania).
  3. Copy the list or export it as CSV, JSON or TXT for fixtures, dropdown mockups or a geography quiz.

Each pick is independent, so a large batch can repeat a code. Everything runs in your browser with the Web Crypto API and nothing is stored. To see full country names first, try:

Pitfalls developers should avoid

  • Case: store codes in uppercase and normalize input, because โ€œdeโ€ and โ€œDEโ€ should match.
  • Language versus country: en is a language code; GB or US are countries. Locales such as en-GB combine both.
  • Hard-coded lists: codes are added and retired over time, so keep your list updatable.
  • Special cases: Kosovo is commonly represented by XK, a code from the user-assigned range rather than an official ISO assignment. Decide how your system handles it.
  • Display names: store the code, not the name, and translate names for each userโ€™s language.

Other country codes you will meet

ISO codes are not the only country abbreviations in daily life, and mixing them up is a classic error:

  • Sports codes: the Olympic movement uses its own three-letter codes, such as GER for Germany and SUI for Switzerland, instead of the ISO alpha-3 DEU and CHE.
  • Vehicle stickers: international vehicle registration codes differ again โ€” Germany is simply D.
  • Currency codes: ISO 4217 currency codes often begin with the countryโ€™s alpha-2 code, as in JPY or CHF, but they are a separate standard.

When a spreadsheet arrives with a โ€œcountryโ€ column, check which system it uses before importing it.

Pro tips

  • Use alpha-2 as your internal key unless a partner system demands alpha-3.
  • Validate against a maintained list rather than a pattern like two capital letters.
  • Test flag display on several devices, since some show letters instead of flags.
  • Quiz yourself on codes that do not match the English name, such as DE, ES and CH.

Frequently asked questions

Who maintains the ISO country codes?

The ISO 3166 Maintenance Agency, part of the International Organization for Standardization, publishes and updates the official lists.

Should I use alpha-2 or alpha-3 codes?

Alpha-2 is the most common choice for web forms, payments and shipping. Use alpha-3 only when a partner system or document format requires it.

Is a country code the same as a calling code?

No. Calling codes such as +44 or +49 are assigned separately for telephone numbers and do not follow the ISO letter codes.

Try a generator

Random Address Generator

Realistic street addresses with valid-format postal codes and phone numbers for 40 countries.

Fake Identity Generator

Complete fictional person profiles: name, birthday, address, phone, email, job and more.

Need random data? Get it now.

Pick any of 144 generators, hit Generate and copy or export the results as CSV, JSON or TXT. No account, no limits, nothing stored.

Start generating โ€” free