Free tool · SEO and webmaster
Hreflang generator
Hreflang tags tell Google which language or regional version of a page to show each searcher, using codes such as en-GB or de. List each version with its URL and this generator writes matching link tags, an HTTP Link header or sitemap entries, with x-default, after checking every code against the ISO lists.
- Free
- No sign-up
- Runs in your browser
- 5 versions
- x-default set
- 6 entries
| Code | Means | URL |
|---|---|---|
| en | English, any region | https://example.com/en/ |
| en-GB | English (United Kingdom) | https://example.com/en-gb/ |
| de | German, any region | https://example.com/de/ |
| fr | French, any region | https://example.com/fr/ |
| fr-CA | French (Canada) | https://example.com/fr-ca/ |
| x-default | Fallback for everyone else | https://example.com/ |
Paste the same block into the <head> of every page listed, so each version names itself and all the others.
How to use the Hreflang Tag Generator
- In Language versions, type one line per version: the code, a space and the full URL, for example
en-GB https://example.com/uk/. - Add an x-default URL for visitors whose language matches none of the versions, or leave it empty.
- Choose HTML tags, HTTP header or XML sitemap under Output as.
- Fix any line the tool refuses, read the checks, then press Copy or Download.
What is hreflang and when do I need it?
Hreflang is an annotation that tells search engines a page exists in other languages or for other regions, and gives the address of each version. Google uses it to show searchers the version in their language. You need it when the same content is available in more than one language, or in one language with versions for different countries, such as separate pages for the United States and the United Kingdom with different prices or spelling.
It does not translate anything, and it is not how Google works out the language of a page: its guide says it does not use hreflang or the HTML lang attribute for that, but reads the content. A page in one language only, for everyone, needs no hreflang at all.
The example in the form lists 5 versions plus an x-default. In HTML, the result is 6 link tags, the first of which is <link rel="alternate" hreflang="en" href="https://example.com/en/" />.
How do I write hreflang codes such as en-GB and en-US?
A code is a language, then optionally a region. The language must be a two-letter ISO 639-1 code, such as en, de or pt. The region, if you add one, must be a two-letter ISO 3166-1 alpha-2 code, such as GB, US or BR. A script can sit between them when a language is written in more than one, as in zh-Hant for Traditional Chinese. Google says the value is not case sensitive; this tool writes the language in lowercase and the region in capitals, the usual convention.
The table shows what the tool does with some typical entries, straight from its checking code.
| You type | Tool writes | Meaning or reason |
|---|---|---|
en | en | English, any region |
EN_us | en-US | English (United States) |
pt-br | pt-BR | Portuguese (Brazil) |
zh-hant-tw | zh-Hant-TW | Chinese (Traditional, Taiwan) |
en-UK | refused | UK is not a valid region code here. The United Kingdom is GB, so use en-GB. |
gb | refused | "gb" looks like a region on its own. A region needs a language first, for example en-GB. |
iw | refused | iw is a withdrawn language code. Use he. |
es-419 | refused | after the language, add an optional four-letter script (Hant) and an optional two-letter region (GB). |
The refused ones are the classic mistakes. A region on its own, such as gb, is not valid: Google needs the language too. UK is not the ISO code for the United Kingdom, and Google says UK, EU and UN in hreflang have no effect, so the tool asks for en-GB. Old codes such as iw (now he for Hebrew) are refused with their replacement. Numeric regions such as 419 for Latin America are not ISO 3166-1 alpha-2 codes, which are the only region codes Google supports.
When you use regional codes for a language, also give one version without a region. Google suggests such a catch-all URL for speakers of that language in regions you did not list. The tool warns when a language appears only with regions.
What does x-default mean?
x-default is a reserved value for the page to show when no other version matches the visitor's language settings. It is often the home page with a language picker, or the main version of the site. In the example, someone browsing in Japanese matches none of the versions, so they would be pointed to the x-default page.
x-default is optional, but it is a good idea whenever you have a language picker or a main version. Type it into its own box, or as a line starting with x-default; the tool refuses it if you put it in both places, so there is only ever one.
The x-default page should be one a visitor can actually use: a page that lets them choose a language, or the version most of your readers understand. Like every other version, it must carry the same block of tags, itself included, so that the links still go both ways.
Does every page need the full set of hreflang tags?
Yes. Google's rule is that each language version must list itself as well as all the other versions. If two pages do not point to each other, the annotations can be ignored. That is why the tool gives one block: you paste the same block into every version listed in it, and each page then names itself and every other page.
The numbers grow fast. With 5 versions and an x-default, each page carries 6 tags, 30 in all across the 5 pages. The sitemap form repeats the full list under every URL, so the same example writes 30 xhtml:link lines. All URLs must be full addresses with https://, which the tool checks line by line.
Should I use HTML tags, an HTTP header or the sitemap?
Google supports all three methods, so choose the one that is easiest to keep correct. HTML link tags go in the head of each page and suit small sites and templates. The HTTP Link header is for files that have no HTML head, such as PDFs. The XML sitemap keeps every annotation in one file, which suits large sites, and it leaves the pages themselves untouched.
For two PDF versions, the header form looks like this: Link: <https://example.com/guide-en.pdf>; rel="alternate"; hreflang="en", <https://example.com/guide-de.pdf>; rel="alternate"; hreflang="de". Whichever method you choose, use one per page rather than mixing them, so that there is a single list to update when a version is added. Once the tags are in place, the meta tag generator covers the rest of the head of each version, and a separate slug for each language keeps the addresses readable.
Use it with
- Slug Generator: turn titles into clean URL slugs.
- SERP Snippet Preview: preview how a page looks in Google.
- UTM Builder: build campaign tracking links.
Questions
What is the hreflang code for the United Kingdom?
en-GB. GB is the ISO 3166-1 code for the United Kingdom; en-UK is refused because Google says the code UK has no effect in hreflang.
Can I use a country code on its own in hreflang?
No. Google needs the language first, so gb on its own is not valid. Write en-GB, or de-DE for German speakers in Germany.
What does hreflang x-default do?
It names the page for visitors whose language matches none of your versions, often a home page with a language picker. It is optional.
Do hreflang tags need to be on every page?
Yes. Each version must list itself and all the others, or the tags may be ignored. With 5 versions and an x-default, that is 6 tags on each page.
Is hreflang case sensitive?
No. Google accepts upper and lower case. Writing the region in capitals, as in en-GB, follows the ISO convention, and this tool does that for you.
Can I use es-419 for Latin American Spanish?
Not with Google. Only ISO 3166-1 alpha-2 regions are supported, and 419 is a numeric region, so the tool refuses it. Use es for a shared Spanish page or country codes such as es-MX.
Sources
How this page was made: the tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations were drafted with AI help and checked against the tool's own output.