Free Tool

Write your hreflang set once

Pick a language for each version of a page and enter its URL. Copy the set as HTML link tags, an XML sitemap or an HTTP Link header. Every code is checked against Google's rules, in your browser.

Language versions

One row per version of the page. Pick from the lists or type the code.

Version ⁦1⁩

Version ⁦2⁩

The page for everyone whose language you don't list, like a language selector. Google recommends it but doesn't require it.

Add a language and a URL for each version of the page.

Put this same block in the head of every page in the set. Each page lists itself and all the others.

Nothing yet. Fill in a row with a valid code and URL.

Test the live pages

After you publish, run our hreflang checker on each version. It reads the set the page serves and opens the alternates to see if they link back.

Open the hreflang checker

Check the sitemap file

Using the sitemap format? Our XML sitemap validator checks the XML, the URLs and the lastmod dates. It does not check the hreflang entries.

Open the sitemap validator
1

Add each version

One row per version of the page. Pick the language, and a script or region if that version targets one. Or type the code.

2

Enter its URL

Use the full URL with https://. Relative URLs are errors, and up to 50 versions fit in one set.

3

Add x-default

If you have a fallback page, like a language selector, enter it. The tool puts x-default last.

4

Copy one format

Pick HTML tags, an XML sitemap or an HTTP header and copy it. The checks run in your browser and nothing is sent.

Hreflang tells Google which language or regional version of a page to show a searcher. Google ignores the tags unless both pages point to each other, so every page in the set needs the full list. For 5 languages that is 5 identical blocks of tags, or 25 xhtml:link lines in a sitemap, and one code like en-UK does nothing. This tool writes the set once and checks each code against the same lists as our hreflang checker.

The rules this tool follows

  1. Google: "Each language version must list itself as well as all other language versions." So the tool writes one set and you put it on every page. For HTML, Google adds: "The set of links is identical for every version of the page."
  2. Google: "Alternate URLs must be fully-qualified, including the transport method (http/https)". A URL like /fr/ or //example.com/fr/ is an error and that row is left out.
  3. Google: "Only language codes listed in ISO 639-1 and region codes listed in ISO 3166-1 Alpha 2 are supported". An optional ISO 15924 script can go between them, like zh-Hant-TW. The tool uses the same code lists as our hreflang checker: 183 languages, 224 scripts and 249 regions.
  4. Google: "You can't specify the country code by itself." So us or gb alone is an error. uk and be pass with a note, because they are languages (Ukrainian and Belarusian).
  5. Google says "using EU, UN, or UK in hreflang annotations doesn't have an effect on Google Search". en-UK is an error and the tool suggests en-GB. Withdrawn codes, like iw for Hebrew, are errors too.
  6. Google: "The hreflang value is case-insensitive". The tool writes the ISO case anyway: language in lower case, script with a capital, region in upper case, like en-GB.
  7. Google says x-default "is recommended for specifying the fallback page for users whose language settings don't match any of your site's localized versions." A missing x-default is a warning, not an error.
  8. Google: "The three methods are equivalent from Google's perspective". Pick one. HTML tags must be "inside a well-formed <head> section". The HTTP header "is useful for non-HTML files (like PDFs)." In a sitemap, each url entry "lists every alternate version of the page, including itself."
  9. Our rule, not a Google quote: one value gets one URL. A value on two URLs is an error and both rows are left out, because the tool can't tell which is right. One URL for two values, like an English page that is also the x-default, is allowed and noted.
  10. Google: "it's a good idea to also provide a catchall URL for geographically unspecified users of that language." If you list en-GB and en-IE but not en, the tool adds a note.

Sources

We read the Google page on 2026-11-12 (it says it was last updated 2026-09-21). The code lists ship with the tool as fixed copies, the same ones our hreflang checker uses.

Worked example: the ayrank.com homepage

These are four of the versions the ayrank.com homepage lists, read with curl on 2026-11-12, entered as rows with the homepage as x-default. The homepage also lists es-ES, pt-PT and ja-JP. They are left out here to keep it short. The tool writes:

<link rel="alternate" hreflang="en-US" href="https://www.ayrank.com" />
<link rel="alternate" hreflang="fr-FR" href="https://www.ayrank.com/fr_FR" />
<link rel="alternate" hreflang="de-DE" href="https://www.ayrank.com/de_DE" />
<link rel="alternate" hreflang="ar" href="https://www.ayrank.com/ar_AR" />
<link rel="alternate" hreflang="x-default" href="https://www.ayrank.com" />

The values and URLs match what the homepage serves. The homepage lists x-default first and the tool puts it last, which is the same set. The French URL path is fr_FR with an underscore, but the hreflang value is fr-FR with a hyphen. A URL can be any path, a value can't. en-US and x-default share one URL, which is allowed, so the tool adds a note.

Frequently Asked Questions

How do I create hreflang tags?

Add one row per version of the page. Pick the language, plus a region or script if that version targets one, and enter the full URL. Add an x-default URL if you have a fallback page. Then copy the HTML tags and put the same block in the head of every page in the set.

Does every page need the same hreflang tags?

Yes. Google says each language version must list itself as well as all other language versions, and that the set of links is identical for every version of the page. Google ignores the tags when two pages don't both point to each other.

Should I use HTML tags, a sitemap or an HTTP header?

Google treats the three as equal, so pick the one that is easiest to keep up to date. HTML tags suit most sites. A sitemap works when you can't edit the head. The HTTP Link header is for files that are not HTML, like PDFs. Using more than one brings no benefit in Search, Google says.

What is x-default and do I need it?

x-default names the page for users whose language settings match none of your versions. Google recommends it and says it was designed for language selector pages. It is optional, so the tool shows a warning, not an error, when it is missing.

Why does the tool reject en-UK or us?

UK is reserved in ISO 3166-1 and is not the code for the United Kingdom, which is GB. Google says UK, EU and UN have no effect, so use en-GB. A country code alone, like us, is not valid because the first code must be a language. Google does not derive the language from a country.

Want us to fix this for you?

This tool writes one hreflang set. Our International SEO work plans and checks hreflang, canonical tags and localized content across every language version of your site.