Hreflang Generator
Generate hreflang link tags from locale and URL pairs, with locale-format validation, duplicate detection, and x-default support.
Processed locally in your browser — nothing is uploaded.
Hreflang Generator
Row 1 (en): the URL is empty.
hreflang tags
Output appears here…Remember: hreflang must be reciprocal. Every URL listed here needs the same set of tags in its own <head>, or search engines ignore the annotations.
About Hreflang Generator
Enter one row per language version and get the matching <link rel="alternate" hreflang> tags for the page's head. Locale codes are checked against BCP 47's common shapes — a bare language (en), language plus region (en-GB), or language plus script (zh-Hans) — and normalised to conventional casing.
Duplicate locales are the most common hreflang mistake after missing reciprocity, so any locale used twice is reported with the row numbers involved. The optional x-default entry tells search engines which URL to serve when no listed language matches the visitor.
Common uses
- Add language annotations to a page that exists in several markets
- Debug a locale code that Search Console flagged as invalid
- Add an x-default fallback to an existing set of hreflang tags
Example
Input
en → https://example.com/ · de → https://example.com/de/
Output
<link rel="alternate" hreflang="en" href="https://example.com/" /> <link rel="alternate" hreflang="de" href="https://example.com/de/" />
Limitations
- hreflang must be reciprocal: every URL listed here needs the same complete set of tags in its own head, or the annotations are ignored
- Region codes are checked for shape only — that a code is well-formed does not mean it is the right market for your page
- hreflang is a signal for which version to show, not a ranking factor or a substitute for translated content
Frequently asked questions
What does x-default mean in hreflang?
x-default marks the URL search engines should serve when none of your listed languages matches the visitor — typically a language-selector page or your primary global version. It is optional, but recommended whenever you have a sensible fallback.
Why is Google ignoring my hreflang tags?
The most common cause is missing reciprocity: every URL in the set must list the same complete group of hreflang tags in its own head, including a self-reference. If page A points to page B but B does not point back, Google discards the annotations for that pair.
What format do hreflang locale codes use?
A language code, optionally followed by a script and/or region, per BCP 47 — en, en-GB, or zh-Hans. This tool checks that shape, converts underscores like en_US to hyphens, and normalises casing to lowercase language, Title-case script, and uppercase region.
Can I use hreflang with just a country code?
No. The value must start with a language — "gb" alone is invalid because hreflang targets languages first and regions second. To target the United Kingdom, write en-GB; to target all English speakers regardless of country, write en.
Are the URLs I list kept private?
Yes. Validation and tag generation run locally in your browser, so unlaunched market URLs or staging domains you paste are never sent to a server or stored anywhere.