# Validate ISO 3166-1 Alpha-2 country codes

- Check 23.06 · Hreflang and regional variants · Critical
- Source: https://checklist-seo-geo.com/en/hreflang-regional-variants/validate-iso-3166-1-alpha-2-country-codes
- Check that every hreflang country code is an assigned ISO 3166-1 alpha-2 code (GB, CH, AT), placed after the language, and remove UK, EU or 419.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/hreflang-regional-variants/validate-iso-3166-1-alpha-2-country-codes.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

In an `hreflang` value, the country is optional. If present, it follows the language after a hyphen and takes the form of a two-letter code from the ISO 3166-1 alpha-2 standard (ISO, the International Organization for Standardization): `fr-CH`, `de-AT`, `en-GB`. Once the task is done, every country code on the site is an officially assigned code, designates the intended country, and is used only when the content genuinely differs from one country to another.

## Why it matters

Google only accepts as a region the codes listed in ISO 3166-1 alpha-2. Its documentation sets three limits:

- **No country on its own**: the first code is always a language. `be` designates Belarusian, not Belgium.
- **No reserved codes**: if you use a code reserved for something else, Google ignores that part of the annotation. It cites `EU`, `UN` and `UK` as examples with no effect; the United Kingdom is written `GB`.
- **No non-standard regions**: `es-419` (Latin America, a numeric United Nations code) is not accepted.

Case does not matter (`fr-ch` is read as `fr-CH`), but the standard's convention is to write the country in uppercase.

A country code changes the target audience. `fr` addresses all French speakers; `fr-CH` French speakers located in Switzerland. Adding a country for no reason therefore restricts the page, and leaving one out mixes two audiences. A country code only makes sense if the page differs for that country: prices and currency, delivery, legal notices, vocabulary. See [distinguish language from geotargeting](https://checklist-seo-geo.com/en/international-architecture/distinguish-language-from-geotargeting).

## What it improves

- **Variants of the same language**: valid `de-DE`, `de-AT` and `de-CH` codes let Google show the page in euros to Germans and the one in francs to the Swiss.
- **Annotations taken into account**: a reserved or malformed code loses the country part, or even the whole annotation.
- **Conversion**: visitors land on their country's page, with their currency and delivery terms.
- **Rankings and AI answers**: no direct effect. No generative engine documents any use of `hreflang` codes.

## How to check

Collect the codes used on the site, in the pages or the sitemap:

```bash
curl -s https://example.com/sitemap.xml | grep -o 'hreflang="[^"]*"' | cut -d'"' -f2 | sort | uniq -c
```

For a list of URLs (`urls.txt`):

```bash
while read -r url; do
  curl -s "$url" | grep -o -i 'hreflang="[^"]*"'
done < urls.txt | cut -d'"' -f2 | sort | uniq -c
```

Correct result: each code is either a language on its own (`fr`), a language followed by an assigned country (`fr-CH`), or `x-default`; the list of countries matches your list of [target countries](https://checklist-seo-geo.com/en/international-architecture/define-target-countries).

Tools:

- **Screaming Frog**: with "Store Hreflang" and "Crawl Hreflang" ticked in `Configuration > Spider > Crawl`, open the Hreflang tab, "Incorrect Language & Region Codes" filter.
- **Merkle's hreflang tester**: checks a URL's codes.

## How to implement

### Step 1 — Validate the country codes

Download the IANA (Internet Assigned Numbers Authority) Language Subtag Registry; its two-letter region codes follow ISO 3166-1 alpha-2, along with reserved, withdrawn or private-use codes that the script rules out:

```bash
curl -s -o registre.txt https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
```

Save this script as `codes_pays.py`:

```python
import sys

RESERVED = {'AC', 'CP', 'CQ', 'DG', 'EA', 'EU', 'EZ', 'IC', 'TA', 'UN'}

subtags = {}

for record in open(sys.argv[1], encoding='utf-8').read().split('%%'):
    fields = {}
    for line in record.splitlines():
        if ': ' in line and not line.startswith(' '):
            key, value = line.split(': ', 1)
            fields.setdefault(key, value)
    if 'Subtag' in fields:
        subtags[(fields['Type'], fields['Subtag'].upper())] = fields

for code in sorted({line.strip() for line in sys.stdin if line.strip()}):
    parts = code.split('-')
    region = parts[-1] if len(parts) > 1 and len(parts[-1]) != 4 else None
    entry = subtags.get(('region', region.upper())) if region else None

    if code.lower() == 'x-default':
        print(f'OK\t{code}\tdefault version')
    elif region is None and ('region', code.upper()) in subtags and ('language', code.upper()) not in subtags:
        print(f'ERROR\t{code}\tcountry code on its own: add the language in front (xx-{code.upper()})')
    elif region is None and ('region', code.upper()) in subtags:
        country = subtags[('region', code.upper())]['Description']
        print(f'TO CHECK\t{code}\tlanguage code, but also the country code for: {country}')
    elif region is None:
        print(f'LANGUAGE ONLY\t{code}\tno country targeted')
    elif region.isdigit():
        print(f'ERROR\t{code}\tnumeric region not accepted by Google')
    elif not entry or 'Deprecated' in entry or entry['Description'] == 'Private use':
        print(f'ERROR\t{code}\t"{region}" is not an assigned ISO 3166-1 alpha-2 code')
    elif region.upper() in RESERVED:
        print(f'ERROR\t{code}\treserved code, with no effect ({entry["Description"]})')
    else:
        print(f'OK\t{code}\t{entry["Description"]}')
```

Run it on the collected codes:

```bash
curl -s https://example.com/sitemap.xml | grep -o 'hreflang="[^"]*"' | cut -d'"' -f2 | python3 codes_pays.py registre.txt
```

Sample output:

```txt
TO CHECK	be	language code, but also the country code for: Belgium
OK	de-at	Austria
ERROR	en-EU	reserved code, with no effect (European Union)
ERROR	en-UK	"UK" is not an assigned ISO 3166-1 alpha-2 code
ERROR	es-419	numeric region not accepted by Google
OK	fr-CH	Switzerland
ERROR	us	country code on its own: add the language in front (xx-US)
```

"TO CHECK" is normal for `fr`, `de` or `es`, which are both languages and countries; it signals a real problem for `be`, `ch` or `ca`, almost always written for a country. To validate the language as well, use the script from [validate ISO 639-1 language codes](https://checklist-seo-geo.com/en/hreflang-regional-variants/validate-iso-639-1-language-codes).

### Step 2 — Fix the wrong codes

| Wrong code | Problem | Correct code |
|---|---|---|
| `en-UK` | `UK` is reserved, with no effect | `en-GB` |
| `en-EU`, `fr-EU` | `EU` is reserved; no code targets Europe | a language on its own, or one code per country |
| `es-419`, `es-LA` | numeric region; `LA` is Laos | `es`, or `es-MX`, `es-AR`… |
| `de-SW`, `fr-SZ` | `SW` is not assigned, `SZ` is Eswatini | `de-CH`, `fr-CH` |
| `de-AU` | Australia, not Austria | `de-AT` |
| `ko-KO`, `ja-JA` | nonexistent countries | `ko-KR`, `ja-JP` |
| `sv-SV` | El Salvador | `sv-SE` |
| `en-EN`, `fr-FRA` | `EN` is not a country, `FRA` is a three-letter code | `en`, `fr-FR` |
| `sr-YU`, `sr-CS` | withdrawn codes (Yugoslavia, Serbia and Montenegro) | `sr-RS`, `sr-ME` |
| `GB-en` | reversed order | `en-GB` |
| `us`, `ch`, `at` | country on its own | `en-US`, `de-CH`, `de-AT` |

Kosovo is a special case: its usual code `XK` is not assigned by ISO 3166-1. No Google documentation states how it is handled: prefer a language code on its own for that audience.

### Step 3 — Keep a country only if it is justified

For each regional code, ask three questions:

1. Does the page differ for this country (currency, prices, delivery, regulations, vocabulary)? If not, use the language on its own.
2. Are there several versions in the same language? If so, also add a generic version of the language (`fr`), for example by annotating the main page with `fr` in addition to `fr-FR`: Google recommends a catch-all page for countries that are not covered.
3. Is the country on your list of target countries? If not, remove the variant rather than half-maintain it.

Example of a consistent group for a German-language store:

```html
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="de-DE" href="https://example.com/de/">
<link rel="alternate" hreflang="de-AT" href="https://example.com/de-at/">
<link rel="alternate" hreflang="de-CH" href="https://example.com/de-ch/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">
```

### WordPress

Versions: WordPress 6.4 to 7.1; WPML 4 and 5, Polylang 3, November 2026.

- **WPML**: `WPML > Settings > Languages` (`WPML > Languages` in older versions), edit the site languages; each language's `hreflang` code field accepts `de-AT` or `en-GB`. For a variant missing from the list, create a custom language.
- **Polylang**: the code comes from the locale chosen for the language (`de_AT` gives `de-AT`). According to Polylang, the country code only appears when several variants of the same language coexist; otherwise, the language on its own is used. To force a country, use the `pll_rel_hreflang_attributes` filter.

### Shopify

Versions: Shopify admin, all plans, November 2026.

The codes follow the markets configuration, and only markets that have their own domain, subdomain or subfolder get them. According to Shopify Help, each code combines a language with an optional country (`fr-CA`, or `fr` for all regions), and each language published on a market also gets a language-only tag. To target a specific country, give it its own market, with a separate URL.

### Drupal

Versions: Drupal 10 and 11.

The `hreflang` code is the Drupal language code (`/admin/config/regional/language`). For a regional variant, create a custom language with a valid code such as `de-at` or `fr-ch`, from the start.

### Laravel

Versions: Laravel 11 to 13.

Keep an explicit mapping table between URL segment and `hreflang` code, for example in `config/app.php`:

```php
'hreflang_codes' => [
    'de' => 'de-DE',
    'de-at' => 'de-AT',
    'de-ch' => 'de-CH',
    'en-uk' => 'en-GB',
],
```

The URL segment can stay `/en-uk/` so as not to break existing links; only the `hreflang` code must be `en-GB`.

### Next.js

Versions: Next.js 15 and 16 (App Router).

The keys of `alternates.languages` become the codes: write `'en-GB'`, even if the route segment is `[lang] = 'uk'`. A single mapping function, shared by the metadata and the sitemap, prevents discrepancies.

### Nuxt

Versions: Nuxt 3 and 4, @nuxtjs/i18n module 9 and 10.

In `@nuxtjs/i18n`, put the country code in the `language` property (`{ code: 'ch-de', language: 'de-CH' }`). For several variants of the same language, the `isCatchallLocale` option designates the locale used as the generic version of the language.

### Astro

Versions: Astro 5 to 7, @astrojs/sitemap integration 3.

In the `i18n` option of `@astrojs/sitemap`, map each segment to its full code: `locales: { de: 'de-DE', 'de-at': 'de-AT', 'de-ch': 'de-CH' }`.

## Common mistakes

- **`en-UK`** for the United Kingdom: a reserved code, ignored by Google. See [use en-GB rather than en-UK](https://checklist-seo-geo.com/en/hreflang-regional-variants/use-en-gb-rather-than-en-uk).
- **Supranational region codes** (`EU`, `419`, `LA` for Latin America): none is accepted.
- **Guessed countries**: `SW` for Switzerland, `AU` for Austria, `SV` for Sweden.
- **Country code first**: `ch-de`, `be-fr`, often copied from a URL segment. They pass validators, because they read as "Chamorro in Germany" and "Belarusian in France": review the decoded language.
- **A country code without adapted content**: the `fr-BE` page is identical to the `fr-FR` page, prices included; Google may index only one of them. See [handle near-identical regional variants](https://checklist-seo-geo.com/en/multilingual-indexing-sitemaps/handle-near-identical-regional-variants).
- **No generic version** when a language has several countries: French speakers in Luxembourg or Morocco have no designated version.

## Frequently asked questions

### Should you add a country code in hreflang?

Only if the content changes from one country to another: currency, prices, delivery, legal notices or vocabulary. A German page identical for Germany, Austria and Switzerland takes the language code on its own, de. If you publish several versions in the same language, add the country code to each and keep a generic version of the language for countries that are not covered.

### Can you target Europe or the European Union with hreflang?

No. The EU code is reserved in the ISO 3166-1 standard, and Google states that reserved codes such as EU, UN or UK have no effect. No code designates Europe as a whole. For a European page in English, use the language code on its own, en, or annotate the same URL for each target country, for example en-IE, en-NL, en-DE, a common practice.

### Must the hreflang country code be in uppercase?

No, it is not mandatory: Google states that the hreflang value is not case-sensitive, so fr-ch and fr-CH are read the same way. The ISO 3166-1 standard does, however, write country codes in uppercase, and Google presents this form as the convention. Adopt it everywhere, in the tags as in the sitemap, to make audits and comparisons simpler.

### Can you target a country in a language that is not official there?

Yes. The code combines a language and a country without checking that the language is officially spoken there: en-DE targets English speakers located in Germany, es-US Spanish speakers in the United States. This is useful for a store that delivers to Germany with an English-language site. The content must then reflect that country: prices in euros, German delivery terms and legal notices.

## Resources

- [Google Search Central: Supported language and region codes](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=en#language-codes)
- [ISO: ISO 3166 country codes](https://www.iso.org/iso-3166-country-codes.html)
- [IANA: Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)
- [Shopify: Use hreflang tags in your theme](https://shopify.dev/docs/storefronts/themes/seo/hreflang)
- [Nuxt i18n: SEO and hreflang](https://i18n.nuxtjs.org/docs/guide/seo)
- [Screaming Frog: Incorrect Language & Region Codes filter](https://www.screamingfrog.co.uk/seo-spider/issues/hreflang/incorrect-language-region-codes/)

Next steps: [Use en-GB rather than en-UK](https://checklist-seo-geo.com/en/hreflang-regional-variants/use-en-gb-rather-than-en-uk), [Use x-default if relevant](https://checklist-seo-geo.com/en/hreflang-regional-variants/use-x-default-if-relevant) and [Test same-language variants for different countries](https://checklist-seo-geo.com/en/hreflang-regional-variants/test-same-language-variants-different-countries).
