New researchTechnical SEO & AI Search · 2027Explore the framework

Free SEO tool · Google hreflang rules

Hreflang Tag Generator & Validator

Build a complete hreflang set for every language version of a page, as HTML tags, an HTTP Link header or XML sitemap entries. Or paste the annotations you already have and see what Google would ignore.

3 formats HTML, header, sitemapRuns in your browser; nothing is sentGoogle's hreflang guide ↗
Quick check

Is this hreflang code valid?

Type a value to see whether Google accepts it and which language and region it means.

Generator

Generate hreflang tags

Add one row per language or regional version of the page. Every version must carry the same full list, including itself, so the output is the same for all of them.

  1. English
  2. English (United Kingdom)
  3. German
  4. French (Canada)

Shown to users whose language matches none of the versions: usually a language selector or your main version.

Put these lines in the <head> of every version listed, before any element that does not belong in the head.

<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Checks on this set

  • Every code is valid, every URL is complete, and each version lists all the others, including itself.

Validator

Validate existing hreflang

Paste a page's HTML source (or just its link tags), an HTTP Link header, or an XML sitemap. The format is detected; a sitemap is checked for return links between its entries.

Tip: in a browser, view-source:https://example.com/ shows the source; curl -I shows headers.

The address of the pasted page, for the self-reference check. Without it, the canonical in the HTML is used.

How it works

The hreflang rules Google applies

The generator follows these rules and the validator checks them, from Google's guide to localized versions of a page.

Three methodsHTML <link> tags, an HTTP Link header or an XML sitemap. Google treats them as equivalent; using more than one gives no benefit in Search.
CodesAn ISO 639-1 language code, optionally followed by an ISO 3166-1 alpha-2 region: de, de-AT. A script can sit between them, as in zh-Hant-TW. Values are case-insensitive.
Invalid regionsA region can't be used on its own, so GB alone is invalid. UK, EU and UN have no effect; the United Kingdom is GB.
Complete setsEach language version must list itself as well as every other version, so the same set appears on all of them.
Return linksIf two pages don't both point to each other, Google ignores the annotations between them.
Full URLsAlternate URLs must be fully qualified, with https://. They can be on different domains.
x-defaultThe reserved value for users whose language or region matches none of the versions. It takes no language code.
PlacementHTML tags must be inside a well-formed <head>. Google stops reading the head at the first element that is not valid there, such as an <img> or <div>.

Sources: Tell Google about localized versions of your page and valid page metadata (Google Search Central).

Next step

Get the whole international setup right

Valid tags on one page are a start. These guides cover the rest of the set and the site around it.

Errors

Fix the common hreflang mistakes

Invalid codes, missing return links, non-indexable alternates, no self-reference and no x-default, with fixes.

Hreflang errors
Migration

Keep hreflang right through a move

Map every old locale URL to its new equivalent and update the whole set with the redirects.

International URL mapping

Good to know

Hreflang generator FAQ

Source: Google Search Central.

How do I generate hreflang tags?

List every language or regional version of the page with its code and full URL, add an x-default if you have a fallback page, and copy the output. Put the same set on every version listed, because each one must list all versions, including itself.

Should I use HTML tags, HTTP headers or a sitemap for hreflang?

Google treats the three methods as equivalent, so use the one your site can keep up to date. HTML tags suit most pages, HTTP headers suit PDFs and other non-HTML files, and a sitemap keeps large sets out of the page head. Using more than one method gives no extra benefit.

Is en-UK a valid hreflang code?

No. Region codes follow ISO 3166-1 alpha-2, where the United Kingdom is GB, and Google says UK, EU and UN have no effect in hreflang. Use en-GB instead.

Do hreflang URLs have to be absolute?

Yes. Google requires fully qualified alternate URLs including the protocol, such as https://example.com/de/. A relative path like /de/ is not valid.

Can I check return links with this tool?

Yes, if you paste an XML sitemap that contains all the versions: each entry is checked against the others. From a single page's HTML, the tool can only check that page's own set; checking return links across a site needs every page crawled.

Check hreflang across the whole site

Crawlens reads the hreflang tags on every crawled page and flags invalid codes, missing return links, alternates that aren't indexable, and sets without a self-reference or x-default.

Download free for Windows