1001Ferramentas
๐ŸŒValidators

ISO 3166 Country Code Validator

Validate ISO 3166-1 alpha-2 / alpha-3 country codes and resolve country name.

ISO 3166-1: the global standard for country codes

ISO 3166-1 is the part of the ISO 3166 family that lists country codes for every sovereign nation, dependent territory and special area recognized by the United Nations Statistics Division. It is maintained by the ISO 3166 Maintenance Agency in Geneva and is the silent backbone of i18n, e-commerce shipping forms, analytics, banking (it feeds the first two characters of IBAN) and domain names (ccTLDs like .br, .us, .de).

The standard publishes three parallel representations of every country, so applications can pick the one that best fits their channel. They are kept in lockstep: changing one triggers an update across the three.

The three variants

  • Alpha-2: two uppercase letters (BR, US, GB, DE, FR, JP). The most common form online โ€” used in URLs, locale identifiers, ccTLDs and HTML lang attributes.
  • Alpha-3: three uppercase letters (BRA, USA, GBR, DEU, FRA, JPN). Preferred by sport governing bodies (FIFA, IOC have their own codes but reference alpha-3) and IATA-adjacent systems.
  • Numeric: three digits (076 BR, 840 US, 826 GB, 276 DE). Script-agnostic, immune to RTL/LTR issues and the only form usable when alphabetic charsets are not available.

Exceptional and user-assigned reservations

Not every two-letter combination is a country. ISO reserves some codes for special purposes: EU is exceptionally reserved for the European Union, UK is exceptionally reserved (the United Kingdom's official ISO code is GB โ€” "United Kingdom of Great Britain and Northern Ireland"). XK for Kosovo is a user-assigned code, not officially in ISO 3166-1. Indeterminate reservations like AN (Netherlands Antilles, retired 2010) stay blocked for at least 50 years.

ISO 3166-2: subdivisions inside a country

When you need to identify a state, province or region, switch to ISO 3166-2. The format is COUNTRY-SUBDIVISION: BR-SP (Sao Paulo), BR-RJ (Rio de Janeiro), US-CA (California), US-NY (New York), GB-ENG (England), DE-BY (Bavaria). Shipping APIs, tax engines and address autocompletes typically use 3166-2 internally.

Codes that changed and codes that never do

Country codes change rarely but it happens: Eswatini kept SZ when it renamed from Swaziland (2018), Czechia kept CZ after the short-form rename (2016), North Macedonia stayed MK (2019) โ€” short names changed in the registry but the codes stood. New entries do appear: South Sudan received SS / SSD / 728 in 2011. Always pin the version of your ISO 3166 library and review release notes once a year.

Where ISO 3166-1 shows up in the stack

  • HTML lang attribute: <html lang="pt-BR"> โ€” BCP 47 reuses ISO 3166-1 alpha-2 as the region subtag.
  • URL locale segments: /pt-br/ (lowercase, recommended by Google) or /pt-BR/ (mixed case, RFC 5646 canonical).
  • Shipping and checkout forms: country dropdowns send alpha-2 or alpha-3 to payment gateways.
  • Google Analytics 4 geo reports: countries returned as ISO 3166-1 alpha-2.
  • GDPR data residency: data localization rules keyed on alpha-2 country code.
  • IBAN: the first two characters of an IBAN are the ISO 3166-1 alpha-2 of the bank's country.
  • Phone country codes: not ISO โ€” that is ITU-T E.164 (+55 Brazil, +1 USA, +44 UK).

Working with ISO 3166-1 in code

Popular libraries:

  • JavaScript: iso-3166, i18n-iso-countries, country-list on npm.
  • Python: pycountry (covers 639, 3166, 4217, 15924).
  • Java: java.util.Locale exposes country codes via getCountry() (alpha-2) and getISO3Country() (alpha-3).
  • .NET: RegionInfo class wraps alpha-2 and alpha-3.

Example in JavaScript:

const countries = require('i18n-iso-countries')
countries.getName('BR', 'en') // "Brazil"
countries.getAlpha3Code('Brazil', 'en') // "BRA"
countries.getNumericCode('BR') // "076"

Common pitfalls

  • UK vs GB: UK is informal and exceptionally reserved; GB is the official ISO code. Use GB in any system that must round-trip with banks, IATA or government APIs.
  • EU is not a country: the EU code is reserved but does not represent a sovereign state โ€” never store it as a citizenship value.
  • Northern Ireland: part of the UK / GB but with separate flag and political identity. Use ISO 3166-2 (GB-NIR) when granularity matters.
  • Kosovo: lacks an official ISO 3166-1 code due to political dispute; user-assigned XK is a de-facto convention.
  • Hong Kong, Macau, Taiwan: have their own ISO codes (HK, MO, TW) despite political sensitivity.

Brazil specifics

Brazil is identified as BR (alpha-2), BRA (alpha-3) and 076 (numeric). Locale pt-BR distinguishes Brazilian Portuguese from European Portuguese pt-PT. The ccTLD is .br (administered by NIC.br / Registro.br). All 26 states + the Federal District have ISO 3166-2 codes from BR-AC (Acre) to BR-TO (Tocantins).

FAQ

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

For most web contexts (URL locales, HTML lang, GA4, checkout forms), alpha-2 is the de facto choice. Alpha-3 is better when you need disambiguation across locales or compatibility with sport bodies. Numeric is the safe pick for script-neutral systems.

Why is the UK code GB and not UK?

Because the country's official ISO name is "United Kingdom of Great Britain and Northern Ireland". ISO 3166-1 derived the alpha-2 from "Great Britain". UK is informally reserved but not the canonical code.

Does the ISO 3166 list change often?

Rarely. New additions average less than one per decade (last was South Sudan in 2011). Name changes are more frequent but seldom break the codes themselves. Subscribe to the ISO Online Browsing Platform feed for notifications.

Does this tool query an external API?

No. Validation runs locally against the bundled ISO 3166-1 table. Nothing is sent to a server.

Related Tools