Hreflang Tag Generator & Validator
List each language version of a page with its absolute URL and get correct hreflang annotations in three formats: HTML link tags for the head, an HTTP Link header, or an XML sitemap with xhtml:link entries. Language and region codes are validated against ISO 639-1 and ISO 3166-1, and the tool warns about duplicates, relative URLs and a missing x-default.
Reviewed by Vincenzo Manto, Founder & Lead Developer · Last updated September 30, 2026
How it works
- 1
Add one row per language version with its language code, such as en-GB, and the absolute URL.
- 2
Fix any warnings shown, for example invalid codes, duplicates or relative URLs.
- 3
Choose HTML tags, HTTP header or XML sitemap, then copy the output into your site.
Example
en https://example.com/en/
it https://example.com/it/
x-default https://example.com/<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="it" href="https://example.com/it/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />What hreflang does
Hreflang tells search engines which language and regional variant of a page to show to which users. Without it, Google may rank the English page for Italian users, or treat translated pages as duplicates of each other. Correct annotations reduce that confusion and improve the click-through rate of international audiences.
The rules that trip people up
URLs must be absolute and canonical, and each language version must return the complete set of alternates, including itself. Region codes cannot be used alone: write en-GB, never just GB. Use x-default for the fallback experience. If a tag points to a redirected or noindexed URL, search engines will ignore it.
Frequently asked questions
Which format should I choose?
HTML link tags in the head are simplest for regular pages. Use the HTTP header for non-HTML files such as PDFs, and the sitemap format for large sites where editing every page head is impractical. Pick one method per page; do not mix them.
What is x-default?
x-default marks the fallback page for users whose language does not match any listed version, often a language selector or your main version.
Do hreflang annotations have to be reciprocal?
Yes. If page A points to page B, page B must point back to A, and every version should list itself. Adding the same complete set of tags to every version guarantees this.
Are the language codes checked?
Yes. The language must be a lowercase ISO 639-1 code, optionally followed by an ISO 3166-1 region or a script such as Hans. Formats like en_GB with an underscore are flagged.
Related tools
Robots.txt Tester & Analyzer
Paste a robots.txt and check whether a URL is allowed or blocked for Googlebot, Bingbot, GPTBot and more.
Schema Markup Generator (JSON-LD)
Generate JSON-LD structured data for FAQ, Local Business, How-to, Product and Article pages.
Open Graph Tag Analyzer & Social Preview
Paste page HTML to preview how it looks on Facebook, X and LinkedIn and spot Open Graph errors.