# hreflang tag generator & checker

> Generate hreflang tags for HTML, XML sitemaps or HTTP headers with every language and country code checked, and test a live page's return links. Free.

Canonical: https://cromagnon.app/tools/hreflang-generator
Last updated: 2026-10-27

- Category: SEO
- Formats: HTML · XML · HTTP HEADER
- Use it: https://cromagnon.app/tools/hreflang-generator (free, runs in the browser)

## What it does

hreflang tells Google which language and country each version of a page is for, so a searcher in Vienna sees your Austrian German page and a searcher in Sydney sees the Australian English one. The tags are simple, but they break easily: a wrong code such as en-UK, a version that doesn't link back, or an address that redirects, and Google quietly ignores the whole set. This tool builds the tags in all three formats Google reads, checks every code against the ISO lists, and checks a live page and the versions it names.

## How to use it

1. List the versions of one page, one per line: the code, a comma, then the full address. Add x-default for everyone else.
2. Read the code table: each code is translated into plain words (de-AT is German, Austria) and wrong ones are explained.
3. Click Fix the codes that can be fixed to correct en_US, en-UK, jp and similar mistakes in one go.
4. Choose HTML tags, XML sitemap or HTTP header, then copy the result or download the sitemap.
5. For many pages, leave a blank line between pages, or paste spreadsheet columns with a first row of codes, and use the sitemap output.
6. To test a site, switch to Check a page, enter one version's address, then click Check return links to open every version it names.

Tip: Pick one place for hreflang, the HTML or the sitemap, and generate it from the same source as your pages. Most hreflang problems come from versions being added or moved without every other version being updated.

## How hreflang codes are written

- **Language**: Two letters from ISO 639-1, in lowercase by convention: en, de, ja, zh, pt. Three-letter codes and names such as english are ignored.
- **Country (optional)**: Two letters from ISO 3166-1 after a hyphen: en-GB, de-AT, es-MX. A country alone (US, DE) isn't valid; the language always comes first.
- **Script (optional)**: Four letters from ISO 15924 between the two, for languages written in more than one script: zh-Hans for simplified Chinese, zh-Hant-TW for traditional Chinese in Taiwan, sr-Latn for Serbian in Latin letters.
- **x-default**: The version for everyone not covered by the other codes: usually your home page, a language picker or your main international version.
- **Case**: Codes aren't case-sensitive, so EN-gb works, but the tool writes them the standard way (en-GB) so they are easy to read.

## The mistakes the tool catches

The most common is en-UK: the United Kingdom's code is GB, so en-UK is ignored. Next come underscores (en_US, a habit from software locales) and country codes used as languages: jp instead of ja for Japanese, cn instead of zh, gr instead of el, dk instead of da, cz instead of cs, ua instead of uk, vn instead of vi, and in, which is India's country code, not Hindi. Some mistakes are valid codes for another language: kr is Kanuri, not Korean (ko), se is Northern Sami, not Swedish (sv), ee is Ewe, not Estonian (et), and uk alone means Ukrainian, not English for Britain. The tool warns about each of these.

Region codes that aren't single countries are also ignored by Google: es-419 (Latin America), en-EU and en-UN. For Spanish across Latin America, use plain es for the shared version, or list each country you target (es-MX, es-AR, es-CO). The tool also flags the same code used for two different addresses, addresses without https:// and the domain, #fragments, a missing x-default and sets with only one version.

## HTML, sitemap or HTTP header

All three work equally well for Google; choose the one that is easiest to keep correct. HTML link tags go in the <head> of every version, and each version lists all the others and itself. That's easy for a handful of languages, but adds many tags to every page on large sites. The XML sitemap puts the same information in one file, with a <url> entry for each address listing all its versions: no page code changes, and simple to generate from a database. The HTTP Link header is for files without a <head>, such as PDFs.

Don't mix methods with different information. If you move hreflang from the HTML to a sitemap, remove the old tags, or Google sees two sets that disagree.

## What the live check tests

Check a page fetches the address once and reads every hreflang link in its <head> and in its Link header. It flags links placed after <head> has ended, which Google doesn't read (a stray <img>, <div> or script output above them closes the <head> early), checks that the page lists itself with its exact address, and warns when the page's canonical tag points somewhere else or the page is marked noindex, since Google then ignores its hreflang.

Check return links opens up to 20 of the versions named. Each must answer 200 without redirecting, list the checked page with exactly the same address (protocol, www and trailing slash included), and call itself by the same code. A missing return link is the most common reason hreflang has no effect: Google only trusts a pair when both pages confirm it. Hreflang placed only in a sitemap isn't seen by this check; paste the sitemap's sets into Create tags to check their codes.

## Tips

- **Final addresses only**: Use the canonical, final address of each version. A link to an address that redirects or returns 404 breaks the pair.
- **Same content, other language**: hreflang is for equivalent pages. Link the German product page to the English product page, not to the English home page.
- **Language-only fallback**: Targeting en-GB and en-US? Add plain en as well, so English speakers in other countries get a sensible version.
- **Don't redirect by location**: Automatic redirects based on IP or browser language can hide versions from Googlebot, which mostly crawls from the US. Suggest a version with a banner instead.
- **Self-canonical**: Each version's canonical tag should point to itself, never to the main language version.
- **Check after changes**: Re-run the live check after adding a language, moving a site or changing URL structure.

## Questions

### Do I need hreflang for one language?

No. hreflang only matters when the same page exists in more than one language or for more than one country.

### Does Bing use hreflang?

Bing gives it little weight and relies more on the content-language meta tag and the html lang attribute, so set those too.

### Is x-default required?

No, but it's recommended. Without it, people outside every listed language and country get whichever version Google guesses.

### Can two countries share one page?

Yes. List the same address under several codes, such as en-IE and en-GB, if one page really serves both.

### Why does Google show the wrong version?

Usually a version doesn't link back, redirects, or is canonical to another page. Run Check return links on the version that should appear and fix what it marks in red.

### Is the page or list I check saved?

No. Tags are built in your browser. A live page is fetched once by our server for the check and isn't kept.

## Related

- [Sitemap Generator](https://cromagnon.app/tools/sitemap-generator)
- [SERP Preview](https://cromagnon.app/tools/serp-preview)
- [Schema Validator](https://cromagnon.app/tools/schema-validator)
- [robots.txt Generator](https://cromagnon.app/tools/robots-generator)
- [All tools](https://cromagnon.app/tools)
