Toolsy

hreflang generator

Generate hreflang in all three formats, with checks for the errors that silently break a language set.

Runs entirely in your browser. Nothing you paste is uploaded or stored.

Language versions
-
-

Where to send everyone whose language you do not publish. Usually the English or the selector page.

Add at least one language and URL on the left.

Put this block on every page in the set, unchanged — each page must list all versions including itself. A missing self-reference or a one-way link is the most common reason a correct-looking set is ignored.

What this tool does

It builds the annotations in all three formats Google accepts and checks the codes as you type — invalid country codes, duplicates, relative URLs and the missing x-default.

Why hreflang breaks so often

It is not a list of translations. It is a graph in which every node must point to every other node, including itself. A set of four language versions means four pages each carrying the same four annotations. Miss the self-reference on one page and that page drops out of the set. Miss the return link and the claim is discarded entirely, because a one-way declaration is unverifiable.

That is why a set that reads correctly on one page can be completely inert: the error is never on the page you are looking at.

The codes

Language is two letters, ISO 639-1. Region is two letters, ISO 3166-1 Alpha-2, and it means country, not language. en-GB is English as served to the United Kingdom; there is no en-UK, because UK is not a country code. There is also no way to say “Europe” — the EU is not a country and hreflang has no concept for it.

Region alone is not allowed either: hreflang="US" is invalid. It is always a language, optionally narrowed by a country.

Choosing a format

Use tags for a small, stable set — they are readable and easy to audit. Use the sitemap form when pages are generated, because it keeps the whole set in one file rather than scattering identical blocks across hundreds of pages. Use headers only where there is no HTML to put tags in, such as a PDF. Never mix formats for the same page.

Questions

Does every page need to list itself?

Yes. A self-referencing hreflang is required — a page that lists its translations but not itself is treated as an incomplete set. This is the single most common implementation error, and it is invisible without a validator.

What are return links and why do they matter?

If page A points to page B, page B must point back to A. hreflang is a mutual declaration, and Google ignores one-sided claims — otherwise any site could claim to be the translation of any other. A tool cannot verify this for you, because it can only see the page in front of it.

Is it hreflang="en-UK"?

No, and this is a classic. The language subtag is ISO 639-1 and the region subtag is ISO 3166-1 Alpha-2, where the United Kingdom is GB. There is also no code for the EU — hreflang targets countries, not unions.

Do I need x-default?

It is optional but recommended. It says where to send visitors whose language is not in your set. Without it, Google picks from your existing versions on its own, which usually means the wrong one for a large slice of your audience.

Tags, sitemap or headers?

They are interchangeable, and you must pick one per page rather than combining them. Tags are simplest for a small set, the sitemap scales better when pages are generated, and headers are the only option for non-HTML files such as PDFs.

Last updated 19 Aug 2026