Hreflang Generator guide
List each language or regional version of a page with its URL and get correct hreflang annotations for international SEO, with built-in checks for the mistakes that make Google ignore them.
What hreflang solves
If you have the same page in several languages, or the same English page tuned for the US, UK, and Australia, Google needs to know they are alternates rather than duplicates. Without that signal, a searcher in London may land on your US page with dollar prices, or your Spanish page may compete with your English one. Hreflang annotations map each version to a language (and optionally a region) so Google can swap in the right URL for each searcher.
Hreflang is a signal, not a directive. Google uses it alongside other clues, and it only works when the annotations are complete and consistent across every version. Most hreflang failures come from small formatting mistakes, which is why the generator validates as you type.
The code format
A valid value is a language code from ISO 639-1 (two letters: en, es, de, ja, zh), optionally followed by a hyphen and a region code from ISO 3166-1 alpha-2 (us, gb, mx, ca). Case does not matter, so en-US and en-us are equivalent. Two less common forms are also valid: a script subtag for writing systems (zh-hant for Traditional Chinese, sr-latn for Serbian in Latin script), and a UN M.49 numeric region, most usefully es-419 for Latin American Spanish.
A region on its own is never valid. hreflang="us" means nothing to Google. The language always comes first.
The special value x-default marks the fallback page for anyone who does not match a listed version, typically a language picker or your primary site.
Worked example: US, UK, Spanish, and German
The sample input has five lines: en-us pointing to the homepage, en-gb to /uk/, es to /es/, de to /de/, and x-default back to the homepage. The HTML output is five link tags, and all five go in the head of every one of those four pages. Yes, each page lists itself too; that self-reference is expected.
Using es without a region means the Spanish page serves Spanish speakers everywhere: Spain, Mexico, and US Spanish speakers alike. If you later add a Mexico-specific page, add es-mx for it and keep es as the catch-all for other Spanish speakers.
Switch the output to XML sitemap and the generator writes one url entry per page, each carrying the full set of xhtml:link alternates. Remember to declare the xhtml namespace on your urlset element, or the sitemap will not validate.
Return tags: the rule that breaks most setups
If page A says page B is its Spanish version, page B must say page A is its English version. Google ignores any pair that is not confirmed from both sides. The simplest way to guarantee this is to generate one block containing every version and paste the identical block onto every version. That is exactly what the generator produces.
The URLs must be the canonical ones. If /es/ has a canonical tag pointing somewhere else, or redirects, or is blocked by robots.txt or noindex, the annotation is wasted. Each listed URL should return a 200 status and canonicalize to itself.
Common mistakes the validator catches
en-uk instead of en-gb: the ISO code for the United Kingdom is GB. jp instead of ja: jp is Japan's country code, but hreflang needs the language code. The same goes for cn (use zh), kr (ko), se (sv), dk (da), cz (cs), gr (el), and ua (uk).
Relative URLs: hreflang requires absolute URLs including the protocol, such as https://example.com/es/, not /es/.
Duplicate codes: two URLs claiming to be en-us leaves Google guessing, so it may ignore both.
What it cannot check: whether your pages actually link back to each other and return 200. Google retired Search Console's International Targeting report in 2022, so after deploying, verify with a crawler such as Screaming Frog or Sitebulb, which report missing return tags.
HTML, sitemap, or header?
All three methods are equivalent to Google. HTML link tags are easiest for a handful of pages. XML sitemaps scale better for large sites, since 10 languages means 10 extra tags in every page head otherwise. HTTP Link headers are for non-HTML resources like PDFs. Pick one method per page; mixing them risks conflicting signals.
How we calculate: sources
Frequently asked questions
What is an hreflang tag?
An annotation that tells Google a page has versions in other languages or for other regions, such as <link rel="alternate" hreflang="es" href="https://example.com/es/" />. Google then shows searchers the version that matches their language and country.
What format do hreflang codes use?
An ISO 639-1 language code, optionally followed by an ISO 3166-1 region code: en, en-us, en-gb, es-mx, fr-ca. You can also use a script (zh-hant) or a UN M.49 region (es-419 for Latin America). A region alone, like "us", is not valid.
Why is en-uk wrong?
UK is not the ISO country code for the United Kingdom; GB is. Use en-gb. Other common mistakes are jp (use ja for Japanese), cn (use zh), and se (use sv for Swedish).
What is x-default?
The fallback URL for visitors whose language or region does not match any version you list, often a language selector or your main English page. It is optional but recommended.
Do hreflang tags need to be on every page?
Yes. Every version must list the full set, including itself. If the English page points to the Spanish page but the Spanish page does not point back, Google ignores the pair. These are called return tags.
Should I use HTML tags or the sitemap?
Either works; Google treats them the same. HTML tags are simplest for small sites. XML sitemaps are easier for large sites because they keep the page head light. HTTP headers are for non-HTML files like PDFs. Pick one method and use it consistently.
Does Bing support hreflang?
Bing relies mostly on the content-language meta tag and other signals rather than hreflang. If Bing traffic matters, add <meta http-equiv="content-language" content="en-us"> as well.
Are my URLs kept private?
Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.