Hreflang Tag Generator
Generate hreflang tags for a multilingual site from a list of locale and URL pairs. Outputs HTML link tags, XML sitemap entries or an HTTP Link header, and flags duplicate locales, bad language codes and relative URLs.
Input
One per line: a language code, then the absolute URL. Comma, tab or space separated.
Shown to visitors whose language matches none of the above.
Use the sitemap or header form when you can't edit the page head (PDFs, for example).
Rewrites en-us as en-US and zh-hant as zh-Hant. Codes are case-insensitive, but canonical casing is easier to audit.
Output
Guides
hreflang tells a search engine that two URLs are the same page in different languages, so a French visitor gets /fr/ instead of the English original. Get it wrong and the annotation is dropped silently — there is no error message, the pages just keep competing with each other.
Paste your locale/URL pairs and this generator writes the markup and audits the set at the same time.
How to use it
Put one alternate per line, language code first:
en-US, https://example.com/
en-GB, https://example.com/uk/
fr, https://example.com/fr/
Comma, tab, semicolon or plain spaces all work as the separator. Add an x-default URL for visitors whose language matches nothing in the list, and pick the output format you can actually deploy:
- HTML
<link>tags — the usual choice, dropped into<head>on every listed page. - XML sitemap entries — a complete
<urlset>with<xhtml:link>children, one<url>block per locale. Best when you have many pages and don't want to bloat every head. - HTTP
Link:header — the only option for non-HTML files. If you localise PDFs, this is how you annotate them.
Leave Normalise locale casing on and en-us becomes en-US, zh-hant becomes zh-Hant. Codes are case-insensitive to crawlers, but canonical casing makes a diff readable.
What the validation catches
The notes pane flags the failures that produce valid-looking markup:
- Duplicate locales — two
en-USentries invalidate the whole set, not just the duplicate. - Country codes used as languages —
us,cn,jpandgraren't ISO 639-1 languages, so those tags are ignored outright. - Codes that mean something else than you think —
ukis Ukrainian, not the United Kingdom;seis Northern Sami, not Sweden;bris Breton, not Brazil. - Relative URLs — hreflang requires absolute, fully-qualified URLs.
- Two locales sharing one URL, which usually means a translation didn't ship.
- A single alternate, which describes no relationship at all.
Do I need return links?
Yes, and it's the most common reason hreflang does nothing. Every URL in the set must serve back the same block, including a self-referencing tag pointing at itself. If /fr/ lists the English page but the English page doesn't list /fr/, the whole annotation is discarded. Because this generator emits one complete block covering every alternate, you can paste the identical output onto every page in the set.
Should the language or the region come first?
Language always comes first: en-GB, never GB-en. The region is optional — use a bare fr when one French page serves every French-speaking country, and fr-CA only when you genuinely have a separate Canadian version.
Privacy
Everything runs in your browser. Your URLs are never uploaded or fetched — the tool reads the list you paste and nothing else.
Related tools
Building the rest of the head? The HTML Meta Tag Generator covers titles, descriptions and Open Graph. To pick the one canonical URL these alternates should point at, use the URL Canonicalizer; to wrap the sitemap output into a full file, see the Sitemap XML Generator.