Hreflang Tag Generator

URLs and locale codes processed locally

Build hreflang tags for international sites. BCP 47 validation, x-default support, and three output formats — HTML, HTTP header, or sitemap.

Language versions

One row per language version of this page. Each gets its own hreflang tag.

x-default (recommended)

The fallback page when no language version matches the user's locale.

x-default is what Google shows when none of your language versions match. Often your English page or a language-selector landing page.

Output format

Pick where you'll declare these tags.

Runs entirely in your browser — nothing is uploaded
Runs entirely in your browser. No uploads. Your files stay private.

Hreflang: Tell Google Which Language Version Belongs Where

Hreflang is the HTML attribute Google introduced in 2011 to help international sites surface the right language version to the right user. Without hreflang, Google has to guess: it might serve your French translation to French users in some queries, but the English original to French-Canadians searching the same product. With hreflang, you make the mapping explicit and Google honours it directly.
Three things matter for hreflang to work. First, every language version must reference every other version including itself — a four-language site needs four hreflang tags on every page, not just on the alternates. Miss the self-reference and Google's validators flag it as an error. Second, the references must be reciprocal — if /en links to /fr as fr, then /fr must link back to /en as en. Asymmetric pairs are silently dropped. Third, locale codes must follow BCP 47 — the IETF spec covering language tags. The two most common mistakes are using underscores instead of hyphens (en_US instead of en-US) and using deprecated codes (zh-CN technically still works but zh-Hans is the modern preferred form for Simplified Chinese).
x-default is the fallback for users whose locale doesn't match any of your language versions. A user in Vietnam visiting a site that has en, fr, and de versions doesn't match any of them — Google will serve whichever the algorithm guesses, unless you explicitly declare x-default. Most sites point x-default at the English version or a language-selector landing page; the choice depends on which path is the better fallback experience.
There are three valid places to declare hreflang. HTML <link> tags in <head> are the most common — visible in dev tools, easy to inspect. HTTP Link headers are the right choice for non-HTML files like PDFs, where you can't add HTML markup. Sitemap xhtml:link entries are useful for very large sites where adding 30 link tags to every HTML page becomes unwieldy. Pick one approach per site; mixing approaches sometimes confuses validators.
The generator validates locale codes against BCP 47 and surfaces the canonical form when you've typed something close-but-not-quite-right (en_us is rewritten to en-US, zh_cn to zh-CN). It also catches duplicate URLs across rows — every locale must have a distinct URL, since the whole point is to map distinct content to distinct locales.
After deploying hreflang, validate with Google Search Console's International Targeting report. Errors there mean Google is ignoring your tags. Common Search Console flags: missing return tags (the reciprocity issue), unconfirmed return tags (set up but not yet crawled), and incorrect language codes (the BCP 47 issue).
All processing happens in your browser. The URL list, locale codes, validation results, and generated output never leave your device. There's no upload because the tool is a string template, a regex validator, and a clipboard write.

Common Use Cases

01

International e-commerce

Shopify and Magento stores with /en, /fr, /de versions of the same product page need hreflang to avoid duplicate-content penalties and surface the right SKU to each region.

02

SaaS marketing site

Localised landing pages for Stripe, Notion, Figma-style tools — each language version of /pricing needs reciprocal hreflang tags so the right page ranks per region.

03

News and media

Per-region news outlets (BBC's en-US/en-GB split, Reuters' en/fr/es) rely on hreflang to keep editions distinct in search results.

04

Hreflang in sitemaps

Very large multi-language sites (10,000+ pages × 5 locales = 50,000+ URLs) prefer sitemap-based hreflang because adding 5+ link tags to every page bloats HTML.

Frequently Asked Questions

Hreflang is an HTML attribute (introduced 2011) that tells Google which language version of a page belongs to which user locale. You need it if you have multiple language or region versions of the same content. Single-language sites don't need it.
Three valid places: HTML <link> tags in <head> (most common), HTTP Link headers (for non-HTML files like PDFs), and sitemap.xml xhtml:link entries (for very large sites). Pick one approach and stick to it across the site.
en is generic English (any region). en-US is English specifically targeted at United States users. If you have one English version that's appropriate everywhere, use en. If you have distinct US vs UK vs Canada English versions, use en-US, en-GB, en-CA.
The most common cause is missing return tags — reciprocity. If page A links to page B as fr, page B must link back to A as en (or whatever A's locale is). The generator's reciprocity check flags duplicate URLs but you're responsible for ensuring every page lists ALL alternates.
zh-Hans is the modern BCP 47 preferred form (script-based: Simplified Han). zh-CN still works but is region-based and technically less precise — China speaks both Mandarin and other languages. For new sites, zh-Hans and zh-Hant are recommended.
x-default is what Google serves when none of your language versions match the user's locale. Without it, Google guesses — usually correctly, but not always. Including x-default removes the guesswork. It's not strictly required but Google's docs recommend it for any multi-language site.
Yes — hreflang is URL-based, not domain-based. Tags like <link rel="alternate" hreflang="fr-FR" href="https://example.fr/page" /> work fine. You'll need the tags on every domain referencing every other domain — hosted-domain hreflang is more complex than single-domain but the principle is identical.
Yes. BCP 47 uses hyphens (en-US). HTTP and many older systems use underscores (en_US). Search engines treat en_US as invalid and ignore the tag. The generator catches this and offers a one-click fix.
Every page that has translated versions. The /pricing page links its alternates; the /about page links its alternates separately. They don't share — each page declares its own set of alternates including itself.
Use the HTTP Link header format. Configure your web server (nginx, Apache, or your CDN) to send Link: <https://example.com/whitepaper-fr.pdf>; rel="alternate"; hreflang="fr" on the PDF response. The generator outputs the correct syntax when you switch to HTTP header mode.

Advertisement