Online Tool Store Online Tool Store
🌏 Education

· 4 min read

How to Look Up Country Codes and Key Facts

Manesh Jayawardhana

CIO & Co-founder

Manesh Jayawardhana is the CIO and Co-Founder of Ceyentra Technologies, where he has spent over nine years leading the design and delivery of software solutions for clients across the globe, spanning web, mobile, AI, and capital market systems. He has grown Online Tool Store's engineering team from the ground up while steering the company's technical direction. His writing draws on this breadth of experience building and shipping software across a wide range of industries and markets. View on LinkedIn

Share

How to Look Up Country Codes and Key Facts

Setting up a shipping form, or a phone number field, or a currency selector. You need the ISO code — but there are three of them, and they’re used by different systems for different reasons.

Getting this right at the start is much easier than migrating a database column later.

The three ISO codes

ISO 3166-1 defines three representations of every country:

Alpha-2 — two letters. LK, GB, US. This is what web development uses: it matches country-code top-level domains and locale identifiers, and it’s what most libraries and browser APIs expect.

Alpha-3 — three letters. LKA, GBR, USA. More readable in reports and printed output, since the abbreviation is usually recognisable.

Numeric — three digits. 144, 826, 840. Language-independent, and the most stable across political change: a country that renames keeps its number.

For most web work, store alpha-2. For anything long-lived or archival, numeric is the safest against renaming. Never store the country name as your key — names change, translate, and are inconsistently punctuated.

Codes that surprise people

Currency codes are a separate standard, ISO 4217, and they don’t always match the country code. Switzerland is CH with currency CHF, but the euro is EUR regardless of which country uses it.

Calling codes aren’t unique per country. +1 covers the United States, Canada and much of the Caribbean; +7 covers Russia and Kazakhstan. Building a phone field that assumes one country per calling code will produce wrong results.

Time zones. Several countries span many zones, and offsets change with legislation. Store an IANA zone name like Asia/Colombo, never a fixed offset — daylight saving rules and even standard offsets are changed by governments at short notice.

FieldStandardGotcha
Country codeISO 3166-1Three forms, pick one deliberately
CurrencyISO 4217Doesn’t map one-to-one to countries
Calling codeITU E.164+1 and +7 cover several countries
Time zoneIANAStore the name, not the offset

Capitals and other awkward fields

Some countries have more than one capital, with legislative, judicial and commercial functions split between cities. South Africa has three; Sri Lanka’s legislative capital is Sri Jayawardenepura Kotte while Colombo is the commercial centre.

A form field labelled “capital” that expects one value is making an assumption that’s wrong for a number of countries. If it matters to your use case, store what you actually need — the largest city, the seat of government — rather than the ambiguous label.

Common mistakes to avoid

  • Storing country names as keys rather than codes.
  • Assuming one calling code means one country.
  • Storing a fixed UTC offset instead of a zone name.
  • Assuming currency and country map one-to-one.
  • Hard-coding a country list that then goes out of date, rather than referencing the standard.

How to do it with Country Info Lookup

The Country Info Lookup shows all three ISO codes alongside currency, calling code, time zones and driving side.

  1. Enter a country name or any of its codes.
  2. Read the card — codes, currency, calling code and zone are the fields usually needed together.
  3. Pick the code form that suits your system: alpha-2 for web, alpha-3 for reports, numeric for archival stability.
  4. Store zone names rather than offsets for anything time-related.

Other reference tools are in the tools directory.

Frequently asked questions

Which ISO code should I use in a database?

Alpha-2 for most web work, since it matches domain and locale conventions. Alpha-3 reads better in reports, and numeric codes survive country renaming best.

Why do some countries have several capitals?

Constitutional functions can be split — a legislative capital separate from the commercial or judicial one. South Africa and Sri Lanka are both examples.

Do time zones ever change?

Yes, more often than people expect. Countries adjust offsets and daylight saving rules by legislation, which is why software should store a zone name rather than a fixed offset.

Final thought

Decide which code form you’re storing before you write the schema. Changing a country key across a live system is one of those migrations that’s never as small as it looks.

Try the free Country Info Lookup

#country-info-lookup#iso-country-code#calling-code#currency-code#online-tools#free-tools