Hreflang Tag Generator

List each language version of a page with its address, add a fallback address if you have one, and get the three forms Google accepts. Every code is checked, and a wrong one is reported with its line number.

Free Runs in your browser Checked Tuesday, November 10, 2026

One row per version: the code, a vertical bar, then the full address. The code may add a region (en-GB) or a script (zh-Hant-TW).

Optional. The page for visitors whose language matches none of the versions, often a language selector.

Result

Check of the rows — Shows whether every code and address is valid, and the first problem if not.
Link elements for the head of each page
XML sitemap with xhtml:link entries
HTTP Link header

This tool runs in your browser. What you enter is not sent to us.

How to use it

  1. Type one row per language version in Language versions: the code, a vertical bar and the full address.
  2. If you have a language selector or a default page, enter its address in Fallback address (x-default).
  3. Read Check of the rows. When it says every version is valid, copy the link elements, the sitemap or the header.
  4. Put the same set on every page and check that each version links back to all the others.

How the codes are checked

The language part must be an ISO 639-1 two-letter code: the Library of Congress list has 183 of them. The optional region must be an officially assigned ISO 3166-1 alpha-2 code, such as GB or TW. Google's guide says that only those two standards are supported, and that the language comes first, so a bare region such as GB is refused.

A script part, such as Hant or Hans, must have four letters. Google's guide says scripts are given in ISO 15924; this tool checks the shape of the script and not the full list. Codes are not case-sensitive, so the tool writes the language in lower case, the region in upper case and the script in title case.

  • en-uk is refused because UK is a reserved code; the United Kingdom is GB, so the tool suggests en-GB.
  • iw, in and ji were changed in 1989 to he, id and yi, so the tool suggests those codes.
  • Codes that match nothing, such as xx, eng or en_US, are refused with the line number.

Three ways to send the same set

Google lists three methods: link elements in the HTML head, HTTP headers, and an XML sitemap. Google says the three are equivalent, so pick the one that is easiest to maintain. The sitemap form needs the xhtml namespace, and each url entry lists every alternate including itself.

The HTTP header method is described for the GET response of any page; Google calls it useful for non-HTML files such as PDFs, and its examples are PDFs. For a web page the link elements or the sitemap are the usual choice. Google also says the Link header returned for every version of a page is identical, so this tool writes one value for the whole set.

Return links and x-default

Each version has to list itself and all the other versions, and every page must point back. Google says: "If two pages don't both point to each other, the tags will be ignored." When a set is hard to keep complete, Google says you may omit some languages on some pages, and it still processes the pairs that point to each other.

x-default names the fallback page for languages that match none of your versions. Google recommends it for language selector pages, and it is written without a language code.

Worked example: three versions and a fallback

The rows en | https://example.com/en/, en-GB | https://example.com/en-gb/ and tr | https://example.com/tr/, with https://example.com/ as the fallback, make four alternates. Every page of the set gets the same four link elements, and the sitemap has one url entry for each of the three pages.

Each url entry lists all four alternates. The status line reads 3 language versions, all valid, because the fallback is not a language version.

Output Count Detail
Link elements 4 hreflang="tr" href="https://example.com/tr/"
Sitemap url entries 3 each lists 4 alternates, x-default included
Link header values 1 the same value on every page, with 4 alternates
Language versions 3 status: 3 language versions, all valid

Frequently asked questions

Which codes are valid?

A language code from ISO 639-1, such as en, tr or zh, may be followed by a four-letter script such as Hant and an ISO 3166-1 region such as GB or TW. Codes are not case-sensitive, and the tool writes them in the standard case.

Why is en-uk reported as an error?

UK is a reserved code in ISO 3166-1, and Google's guide says that UK in hreflang has no effect. The United Kingdom's assigned code is GB, so the correct tag is en-GB.

Do I need an x-default row?

It is optional. Google calls x-default the fallback for languages that match none of your versions, and recommends it for language selectors. The tool adds it only when you enter an address.

Must every page list the whole set?

Each version must list itself and every other version. Google says tags are ignored when two pages do not point to each other, but it also says you may omit a language on some pages and it will still process the pairs that link to each other.

Why does the tool accept only https addresses?

It accepts absolute https addresses, which most sites use now. Google requires fully qualified addresses that include the transport method, so a site that still runs on plain http needs its annotations written by hand.

Is the HTTP header method meant for web pages?

Google describes it for the GET response of any page and calls it useful for non-HTML files such as PDFs. For web pages the link elements or the sitemap are the usual choice.

Does the tool send my addresses anywhere?

No. The result is built in your browser from the text you enter, and nothing is sent to a server.

Sources

Figures and text last checked on Tuesday, November 10, 2026.

We use necessary cookies to run the site. With your consent, Google also uses advertising cookies to show personalised ads. If you reject them, you still see ads, but they are not personalised.