Free tool
Hreflang tag generator
This hreflang tag generator builds the HTML tags, XML sitemap entries or HTTP headers for every language and country version of a page. It checks each code against the rules Google publishes, including the mistakes most generators let through, such as UK instead of GB.
Versions of the page
Add one row for each language or country version, including the page you start from. Mark the fallback page as x-default.
Generate for several pages (optional)
With paths added, the URLs above become base URLs such as https://example.com/de/, and the generator builds a full set for each page.
Step by step
How to use this hreflang tag generator
- Add every version. One row for each language or country version of the page, including the one you started from.
- Set the codes. A language is required. Add a country only when a version is written for one country, such as en-GB for the United Kingdom.
- Mark the fallback. Tick x-default on the page for visitors who match none of your versions, often a language selector.
- Fix what is flagged. Errors block the output, so nothing broken reaches your site. Warnings are worth a second look.
- Copy one format. Add the result to every version listed, not only the page you started from.
Formats
HTML tags, sitemap or HTTP header: which to use
- HTML tags go in the head of each page. They suit most sites with a handful of versions. If you are editing the head anyway, the meta tag generator covers the title and description.
- An XML sitemap keeps the page code clean and is easier to maintain on larger sites. Submit it in Search Console.
- An HTTP header is for files that have no HTML head, such as PDFs.
Google supports all three. Use one per set of pages, because mixing them makes mistakes harder to track down.
The rules
What Google checks in hreflang
- The language code comes first, in ISO 639-1 format, such as en, de or hi.
- A country is optional and uses ISO 3166-1 alpha-2, such as GB, US or IN. A country on its own is not allowed.
- A script can be added in ISO 15924 format, such as zh-Hant for Traditional Chinese.
- Codes are not case sensitive.
- Each version must list itself as well as every other version.
- Pages have to link to each other. If page A names page B but B does not name A, Google ignores the pair.
- URLs must be complete, including https://.
- x-default is recommended for visitors who match none of your versions.
These come from Google’s documentation on localized versions, which was last updated in September 2026.
Validation
Mistakes this generator catches
- UK instead of GB. The United Kingdom’s code is GB.
- A country code in the language slot, such as jp, cn, dk, gr, ua or cz. The languages are ja, zh, da, el, uk and cs.
- Group codes Google ignores, such as EU, UN and 419 for Latin America. List the countries instead.
- Retired codes, such as iw for Hebrew or in for Indonesian. Use he and id.
- Valid codes used by mistake. se is Northern Sami, not Swedish (sv), and kr is Kanuri, not Korean (ko).
- Relative URLs, one hreflang value pointing at two URLs, more than one x-default, and a mix of http and https.
Bulk
Hreflang tags generator for many pages
Most sites translate more than one page. Open “Generate for several pages” and list the paths, such as / and /pricing/. The URLs in the table then act as base URLs, so https://example.com/de/ plus /pricing/ becomes https://example.com/de/pricing/, and the generator builds a complete set for every page.
For more than a few pages, the XML sitemap is the easiest format to keep right. Download it, upload it to your site and submit it in Search Console.
FAQ
Questions about hreflang
What does the hreflang tag do?
It tells Google which versions of a page are meant for which language or country, so searchers are shown the version that matches them. It is not a ranking boost. It helps Google swap in the right URL from a set of equivalent pages.
How do I add hreflang tags?
Pick one method: link tags in the head of each page, entries in your XML sitemap, or an HTTP header for files such as PDFs. Whichever you use, every version has to list all the others and itself.
Do I need an x-default?
It is recommended rather than required. It tells Google which page to show when a searcher’s language matches none of your versions, often a language selector or your main international page.
Is hreflang case sensitive?
No. Google accepts upper and lower case, so en-gb and en-GB mean the same. The generator writes the usual form: a lower-case language and an upper-case country.
Should I use en-UK or en-GB?
en-GB. UK is not the ISO 3166-1 code for the United Kingdom, and Google lists it as a common mistake.
How do you pronounce hreflang?
Usually as H-ref-lang, because the name joins the HTML href attribute and lang.
Is this hreflang tag generator free?
Yes. It runs in your browser, there is no sign-up, and the URLs you enter stay on your device.
Running a site in more than one country?
Book a 30 minute call. I will check how Google is treating your language versions and whether the right one is showing in each market.