hreflang Tag Generator
The hreflang Tag Generator turns a list of language codes and URLs into the exact markup search engines expect.
100% in-browser ยท no data sent
It validates every code against the BCP 47 shape hreflang actually accepts, normalises casing, catches duplicate codes and relative URLs, and warns when x-default is missing โ then outputs HTML link tags, a sitemap fragment, or an HTTP Link header for non-HTML files.
Embed This Tool
Add this tool to your website with customizable styling
How to Use
Add a row per language
Enter a language code such as en, en-GB or es-419, and the absolute URL of that version of the page.
Add x-default
Point x-default at the page that should serve visitors whose language you do not target. Search engines treat it as the fallback.
Fix any flagged issues
Errors block the output โ invalid codes, relative URLs and duplicate codes. Warnings are worth reading but do not stop generation.
Pick a format and copy
Choose HTML link tags for the page head, sitemap XML for large sites, or the Link header for PDFs and other non-HTML documents.
Frequently Asked Questions
What is x-default and do I need it?
x-default names the page shown to visitors whose language and region you have not targeted โ typically a language selector or your primary market. It is not mandatory, but without it search engines pick a fallback for you, so the tool warns when it is missing.
Do hreflang tags have to be reciprocal?
Yes. Every page in the cluster must list every alternate, including a self-reference back to itself. If page A points at B but B does not point back at A, search engines ignore the whole annotation. That is why the sitemap output repeats the same alternate block inside each url entry.
Which format should I use?
HTML link tags in the head are simplest and right for most sites. Sitemap XML keeps the markup out of your pages and scales better across thousands of URLs. The HTTP Link header is the only option for non-HTML documents such as PDFs, which have no head to put tags in.
Why is my language code rejected?
hreflang accepts a language, optionally a script, and optionally a region โ for example en, zh-Hant, en-GB or es-419. A country on its own is not valid, and neither are longer BCP 47 variants and extensions. The tool checks that shape and normalises the casing to the conventional en-GB form.