Hreflang Tag Generator
Add each language version of your page, set an x-default, and get a validated hreflang tag set in HTML, HTTP header, and XML sitemap formats — with copy buttons.
Updated
Alternate #1
How to use Hreflang Tag Generator
The Hreflang Tag Generator helps international SEO teams produce correct hreflang annotations for language and regional page variants without hand-writing markup. Add each localized URL with its ISO 639-1 language code and optional ISO 3166-1 region code, include an optional x-default fallback URL, and the tool instantly outputs three implementation formats: HTML link tags for page heads, HTTP Link headers, and XML sitemap xhtml:link blocks. It validates locale codes, flags duplicates that can confuse crawlers, and runs entirely in your browser so unreleased URLs stay private.
- Add one row per localized URL and enter a two-letter language code such as en, de, or fr.
- Optionally add a two-letter region code like US or GB when country targeting matters.
- Fill the x-default URL field if you have a language selector or global fallback page.
- Click Generate to validate codes, detect duplicates, and build output snippets.
- Copy the HTML, HTTP header, or XML sitemap format and paste it into your deployment workflow.
Your data never leaves your device — 100% private processing.
How hreflang syntax should be built
A valid hreflang value starts with a two-letter ISO 639-1 language code, optionally followed by a hyphen and a two-letter ISO 3166-1 region code, such as en, en-GB, or es-MX. Every localized version should reference every other version, including itself, so the alternate set is fully reciprocal. If you serve users through a language selector page, include x-default as a neutral fallback. Use absolute canonical URLs, keep protocols consistent, and avoid mixing trailing-slash variants in the same set. Search engines ignore malformed codes and can drop entire clusters when reciprocal mapping is broken, so validation before publishing is essential.
| Pattern | Example | When to use |
|---|---|---|
| Language only | fr | Same content across all French-speaking regions |
| Language + region | en-GB | Country-specific variants with local spelling or pricing |
| Fallback | x-default | Language selector or global default landing page |
Choosing between HTML, headers, and XML sitemaps
Search engines accept hreflang annotations in three places: HTML head tags, HTTP Link headers, or XML sitemap entries with xhtml:link nodes. For standard pages under direct template control, HTML is the simplest and most transparent option. HTTP headers work best for non-HTML resources such as PDFs where no document head exists. XML sitemaps are convenient when your SEO team manages alternates centrally and wants one machine-generated source of truth. Regardless of format, ensure the same alternate mapping appears consistently, keep canonical tags aligned to each locale URL, and avoid declaring conflicting locale pairs across different channels.
Worked examples
English-US and German alternates
Inputs: en-US → /us/page, de-DE → /de/seite, x-default → /
Result: Outputs matching HTML tags, HTTP Link headers, and XML xhtml:link entries
Language-only alternates
Inputs: en → /en/product, fr → /fr/produit
Result: Builds reciprocal alternates without region subtags
Glossary
- hreflang
- A link annotation that signals language and optional regional targeting for equivalent page variants.
- ISO 639-1
- The two-letter language code standard used for the first segment of hreflang values.
- ISO 3166-1 alpha-2
- The two-letter country or region code standard used as the optional second hreflang segment.
- x-default
- A fallback hreflang value for users whose language or region does not match listed alternates.
- Reciprocal mapping
- A requirement that each alternate URL references all other alternates in the same set.
Related reading
Frequently Asked Questions
Get weekly tool tips & updates
New tools, power-user tips, and productivity hacks — delivered free every Friday.
No spam, ever. Unsubscribe with one click.
Why use Hreflang Tag Generator?
- Validates ISO 639-1 language and ISO 3166-1 alpha-2 region codes before you deploy tags
- Generates matching HTML, HTTP header, and XML sitemap hreflang output from one input table
- Highlights duplicate locale values or repeated URLs that often cause hreflang conflicts
- Supports x-default fallback links for global selectors and unmatched locales
- Client-side generation means no localized URL list is uploaded anywhere
Common use cases
- Launch a multilingual product page and create a complete alternate set for all locales
- Audit existing hreflang mappings after a CMS migration to catch duplicate locale codes
- Generate XML sitemap hreflang blocks for markets where head tag editing is difficult
- Create HTTP Link header syntax for non-HTML assets like PDFs served in multiple languages
- Prepare a validated x-default fallback mapping for international homepages
Related Developer Tools
XML Sitemap Generator
Generate a valid XML sitemap for your website. Add your URLs, set change frequency and priority, then download the sitemap.xml.
Google SERP Snippet Preview
Preview how your page title, meta description, and URL appear in Google search results. Check pixel widths, spot truncation, and fix snippets fast.
Schema Markup Generator (JSON-LD)
Generate valid JSON-LD structured data for Article, FAQ, HowTo, LocalBusiness, Product, and Breadcrumb schemas. Free, instant, and fully in-browser.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Includes syntax highlighting, error detection, and a collapsible tree view — free, private, in-browser.
Regex Tester
Test and debug regular expressions online. See live matches, capture groups, and replace output. Free, private, instant.
Base64 Encoder & Decoder
Encode text or files to Base64, or decode Base64 strings back to text. Fast, free, and runs entirely in your browser.
Explore all Developer Tools.