Hreflang Tag Generator — HTML, XML Sitemap & HTTP Header Output | LazyTools
🌐 Hreflang Tag Generator

Hreflang Tag Generator — HTML, XML & HTTP Header Output

Add your locale–URL pairs and get valid hreflang tags in three formats simultaneously: HTML <link> tags for the <head>, XML sitemap syntax, and HTTP Link header format. Built-in validation catches missing self-references, non-bidirectional links, and invalid ISO codes. Supports x-default, base URL auto-fill, and 60+ locale codes.

3 output formats Live validation Auto x-default 60+ locale codes Base URL auto-fill Download .txt
ADSENSE — 728×90 LEADERBOARD
🌐 Hreflang Tag Generator

Add locale–URL pairs — get HTML, XML sitemap, and HTTP header hreflang tags instantly

Base URL (optional — auto-fills new rows)
Auto x-default (uses first URL)
Locale code URL
Add locale-URL pairs on the left to generate hreflang tags.
ADSENSE — 728×90 LEADERBOARD
🔍
Need to audit your existing meta tags?
The free Meta Tag Generator creates optimised title, description, Open Graph, and Twitter Card tags with a live SERP preview — perfect alongside hreflang implementation.
🔍 Meta Tag Generator →
⭐ Ratings

Rate this tool

4.9
★★★★★
Based on 8,200 ratings
5
7,380
4
574
3
164
2
82
1
0
Did this tool save you time?
Thank you for rating!
📖 How to Use

How to generate hreflang tags

1
Enter your base URL
Optionally enter your site’s base URL (e.g. https://example.com). New locale rows will auto-fill with this URL so you only need to add the path suffix for each locale.
2
Add locale-URL pairs
Click “Add locale”, select a language-country combination from the searchable dropdown, and enter the full URL for that locale. Repeat for every language or regional version of the page.
3
Enable x-default
Keep “Auto x-default” on to automatically add an hreflang x-default tag pointing to your first URL. This specifies the fallback page for users whose language isn’t matched.
4
Check validation
The validation panel shows green checks for correct implementation and flags errors: missing self-reference, invalid ISO codes, and empty URLs. Fix any errors before implementing.
5
Choose output format
Switch between HTML link tags (for the page head), XML Sitemap format (for your sitemap.xml), and HTTP Link header (for server configuration). All three update instantly.
6
Copy or download
Click “Copy output” to copy the current tab’s code to clipboard, or “Download .txt” to save the file. Add the HTML tags to each page’s head section, or submit the XML sitemap via Google Search Console.
✔ Key Features

The most complete free hreflang tag generator

📤
3 Output Formats
HTML link tags for the page head, XML sitemap hreflang format, and HTTP Link response headers — all generated simultaneously. Switch tabs to see each format instantly.
Live Validation
Real-time checks for missing self-references (every page must reference itself), invalid locale codes, empty URL fields, and x-default presence. Flags errors before you implement.
🌍
60+ Locale Codes
Searchable dropdown with all major ISO 639-1 language + ISO 3166-1 country combinations. Includes language-only codes (en, fr, de) and regional pairs (en-US, en-GB, zh-CN, zh-TW).
Auto x-default
Toggle to automatically include hreflang="x-default" pointing to your first URL. x-default specifies the fallback page when no other locale matches the user’s language.
Base URL Auto-fill
Enter your site base URL once. Every new locale row auto-fills with it — you only need to add the locale-specific path. Saves time when generating tags for the same page across many locales.
💾
Download .txt
Download any output format as a .txt file for implementation reference. Useful for sharing with developers or keeping a record of your hreflang configuration per page.
📋
One-Click Copy
Copy the entire generated output to clipboard with a single click. Paste directly into your page’s head section, sitemap, or server configuration file.
🔓
Free, No Account
100% free with no sign-up, no limits on locales, and no premium tier. Generate hreflang tags for as many pages and locales as you need.
📱
Mobile Friendly
Fully responsive layout that works on any screen size. Generate and copy hreflang tags from your phone or tablet when you’re working on the go.
📊 Comparison

LazyTools vs other hreflang generators

Feature LazyTools Aleyda Solis SISTRIX GeoTargetly
Output formats✅ HTML + XML + HTTP⚠ HTML only⚠ HTML only⚠ HTML only
Live validation✅ Real-time❌ No❌ No❌ No
Auto x-default toggle✅ Yes⚠ Manual⚠ Manual⚠ Manual
Base URL auto-fill✅ Yes❌ No❌ No❌ No
Download output✅ .txt download❌ No❌ No❌ No
Account required✅ None✅ None⚠ Login❌ Account
Locale limit✅ Unlimited⚠ 50 URLs✅ Unlimited❌ Paid tiers
📐 International SEO Guide

Hreflang Tags — Complete Guide to International SEO Implementation

Hreflang tags are HTML attributes that tell search engines which language and regional version of a page to show users based on their preferences. Without them, a search engine may show your US English page to a UK user, your English homepage to a French speaker, or treat regional variants as duplicate content. Correct hreflang implementation is foundational for any website serving multiple countries or languages.

What is hreflang?

Hreflang (formally rel="alternate" hreflang) is an HTML link attribute introduced by Google in 2011. It signals three pieces of information to search engines: (1) that a page has alternate versions, (2) which language and/or region each version targets, and (3) the URL of each alternate. Google, Yandex, and Bing all support hreflang. Other search engines typically ignore it but are not harmed by it.

The basic syntax is:

<link rel="alternate" hreflang="en-US" href="https://example.com/us/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Hreflang language and country codes

Hreflang valueCodeMeaning
English (any)enEnglish language, any country
English (US)en-USEnglish, United States
English (UK)en-GBEnglish, United Kingdom
English (Australia)en-AUEnglish, Australia
FrenchfrFrench, any country
French (France)fr-FRFrench, France
GermandeGerman, any country
SpanishesSpanish, any country
Spanish (Spain)es-ESSpanish, Spain
Spanish (Mexico)es-MXSpanish, Mexico
Chinese Simplifiedzh-CNChinese, China (Simplified)
Chinese Traditionalzh-TWChinese, Taiwan (Traditional)
JapanesejaJapanese
Fallbackx-defaultShown when no locale matches

Three ways to implement hreflang

1. HTML head section (most common) — Add link tags inside the <head> of every page in the hreflang group. Simple to implement, no server configuration needed. Must be added to every page variant.

2. XML Sitemap — Add <xhtml:link> elements within each <url> block in your sitemap.xml. Best for large sites where adding tags to every page is impractical. Submit via Google Search Console.

3. HTTP Link headers — Configure your web server to send Link response headers. Best for non-HTML resources (PDFs), or when you can’t modify page HTML. Requires server configuration (Apache, Nginx, CDN rules).

The bidirectionality requirement

The most common hreflang mistake is one-directional implementation. Every page in a hreflang group must reference every other page in the group — including itself. If your English page references your French page, the French page must also reference the English page AND reference itself. Google validates hreflang by checking that all referenced pages confirm the relationship. If any page is missing from the reciprocal references, Google may ignore the entire hreflang set for that page.

Example: you have three pages — English (en), French (fr), German (de). Each page must contain all three <link rel="alternate"> tags: one pointing to en, one to fr, one to de, plus x-default.

Hreflang and canonical tags

Hreflang and canonical tags serve different purposes and can coexist. The canonical tag (<link rel="canonical">) tells search engines which URL to index when there are duplicates. Hreflang tells search engines which language/region version to show to which users. Both should point to the correct self-referencing URL on each page. Do not use a single canonical tag pointing to only one language version across all variants — each page should canonical to itself.

Common hreflang implementation mistakes

MistakeImpactFix
Missing self-referenceGoogle ignores hreflang for that pageEvery page must include its own hreflang tag
Non-bidirectionalGoogle may ignore the entire groupAll pages in group must reference each other
Relative URLsTags are ignoredAlways use absolute, fully-qualified URLs
Wrong ISO codesTags are invalidUse ISO 639-1 for language (en, not english), ISO 3166-1 for country (US, not USA)
Missing x-defaultNo fallback for unmatched usersAdd hreflang="x-default" pointing to default URL
zh-Hans / zh-HantGoogle doesn't recognise script codesUse zh-CN (Simplified) or zh-TW (Traditional)

When do you need hreflang?

You need hreflang if your website has: content in multiple languages, the same content in one language targeting multiple countries (e.g. en-US and en-GB), or a mix of both. You do NOT need hreflang if your site is in a single language targeting a single country, or if all regional differences are handled by a single URL with user-side localisation (e.g. currency shown by IP without different page URLs).

❓ FAQ

Hreflang tag generator FAQ

An hreflang tag tells search engines which language and regional version of a page to show specific users. Implemented as link rel="alternate" hreflang="en-US" in the HTML head, XML sitemap, or HTTP header. Essential for multilingual and multi-regional sites.

hreflang="x-default" specifies the fallback page shown when no other locale matches the user. Use it for your language selector page or default English version. Not required, but strongly recommended for international sites.

Yes. If page A references page B, page B must reference page A. Every page in the group must link to every other page AND to itself. Google validates this mutual confirmation. One-directional hreflang may be ignored entirely.

Format: link rel="alternate" hreflang="language-REGION" href="https://absolute-url". Language: ISO 639-1 (en, fr, de). Country: ISO 3166-1 Alpha 2 (US, GB, FR). Examples: en (any English), en-US (US English), zh-CN (Simplified Chinese), x-default (fallback).

Three options: (1) HTML head section of every page. (2) XML sitemap (xhtml:link elements). (3) HTTP Link response headers. HTML head is most common. XML sitemap is best for large sites. HTTP headers for non-HTML files or when you can't edit HTML.

Yes, if you have separate pages for en-US, en-GB, en-AU, en-CA. Without hreflang, Google may show the wrong regional version or treat them as duplicates. Use en-US, en-GB, en-AU plus x-default for the default version.

Missing self-reference (every page must include its own hreflang tag). Non-bidirectional. Relative URLs (must be absolute). Wrong ISO codes (en not english, US not USA). Missing x-default. Using zh-Hans/zh-Hant instead of zh-CN/zh-TW.

Canonical: which URL to index (deduplication). Hreflang: which language/region version to show specific users. They coexist. Each page should canonical to itself AND have hreflang tags. Do not canonical all language versions to one URL.

Use zh-CN for Simplified Chinese (mainland China) and zh-TW for Traditional Chinese (Taiwan). zh-HK for Traditional Chinese Hong Kong. Do NOT use zh-Hans or zh-Hant — Google does not support script subtags in hreflang.

Not directly, but it prevents ranking cannibalization, ensures the correct regional version appears in the right country's SERPs, and reduces bounce rates (users see their language). Correct hreflang makes your international SEO strategy work as intended.

Best options: Yoast SEO plugin (auto-generates for multilingual setups), WPML plugin (handles automatically), Rank Math (supports configuration). Or manually via functions.php wp_head() hook. For large sites, XML sitemap method is cleanest.

The LazyTools Hreflang Tag Generator is 100% free with no account required. Add unlimited locale-URL pairs, get HTML, XML, and HTTP header output, validate, and download. No limits, no premium tier.

No official Google limit. Most sites have 2-30 variants. For 50+ variants, use the XML sitemap method rather than HTML head tags — it's easier to maintain and keeps HTML pages lighter. This tool has no limit on locale rows.