Hreflang Tag Generator and Validator
Enter one row per language version and get the annotation in all three valid forms: <link> tags for the head, an HTTP Link header for PDFs and other non-HTML files, and the xhtml:link sitemap variant. Every row is checked against the real code lists as you type, because an invalid language tag does not degrade — it makes search engines ignore the whole cluster.
Locales and URLs
Markup
Add at least one valid locale and URL to generate the markup.
Ship the localized pages themselves
Moda builds and hosts multi-market marketing sites, so each locale gets a real page rather than a redirect.
Try Moda free →The four mistakes that break hreflang
A country code in the language position — hreflang="us" — is invalid, because the first subtag is always a language: you want en-US. An underscore instead of a hyphen (en_US) is invalid for the same silent reason. "UK" is not a country code at all; the ISO 3166-1 code for the United Kingdom is GB, which is why hreflang="en-UK" is the single most common bug in the annotation. And a relative href does not work: every URL must be fully qualified, scheme included. This tool rejects all four with the correction spelled out.
Return links, and why one block goes on every page
hreflang is only honored when the references are reciprocal: if the English page points at the German one, the German page must point back at the English one, and both must point at themselves. Search engines drop a one-way annotation entirely rather than guessing. The practical consequence is that there is nothing to customize per page — the same complete block, self-reference included, goes into every page in the cluster. That is exactly what this generator emits, which is why the return-link requirement is satisfied by construction rather than by a checklist.
What x-default is actually for
x-default names the page to serve a visitor whose language and region match nothing else in the cluster — a language selector, or the international English version. It is optional, and this tool warns rather than errors when it is missing, because a cluster without one is valid but leaves the fallback to guesswork. x-default is a URL that usually already appears in the cluster under its own language tag, so the two annotations sit side by side rather than competing.
Choosing between the three forms
Link tags in the head are the default and the easiest to inspect. The HTTP Link header is the only option for non-HTML resources — a PDF datasheet in six languages has no head to put tags in. The sitemap form moves the whole cluster out of the page, which is what large multi-market sites do once the block would add kilobytes to every response. Pick one. Using two forms at once does not reinforce the annotation; it just gives you two places for them to disagree.
Frequently asked questions
Is the language code required, and the region optional?
Yes, in that order. hreflang="de" targets German speakers anywhere; hreflang="de-AT" narrows it to Austria. A region alone is never valid. Scripts fit between them for languages that need one — zh-Hant-TW for traditional Chinese in Taiwan — and this tool cases each subtag conventionally in the output.
Can two locales point at the same URL?
It is legal and the tool only warns. It is usually a sign that one of the two should not be in the cluster: if en-US and en-CA are the same page, en covers both, and the extra row adds an alternate that resolves to itself. x-default is the deliberate exception — it is expected to duplicate a URL already in the cluster.
Does hreflang help my rankings?
No. It does not raise or lower anything. It tells a search engine which of your equivalent pages to show a given user, so the right regional version appears in results instead of a competing one of your own. The benefit is the right page reaching the right visitor, not a position change.
Do I still need canonical tags?
Yes, and each page should canonicalize to itself. A localized page whose canonical points at a different language version is telling the search engine those pages are the same page, which contradicts the hreflang annotation saying they are alternates — and the contradiction usually wins.
How does the tool know which codes are valid?
It checks the language subtag against the ISO 639-1 list and the region subtag against ISO 3166-1 alpha-2, plus three-digit UN M.49 region codes for supranational areas such as 150 for Europe. Longer ISO 639-2/3 tags pass too, since some languages — Filipino (fil), Hawaiian (haw), Cebuano (ceb) — have no two-letter code; a three-letter code for a language that does have one (eng, deu) is flagged, because BCP 47 wants the shorter tag. Deprecated language codes (iw, in, ji, mo) are accepted with a warning naming the current code, because they still resolve but should be migrated.