Hreflang Tag Generator
Generate valid, reciprocal hreflang tags for multilingual and multi-regional websites
Updated
What is the Hreflang Tag Generator?
The Hreflang Tag Generator is a free, browser-based tool for creating valid, Google-compliant hreflang annotations for multilingual and multi-regional websites. It helps search engines serve the right language version of a page to users based on their language and location.
Hreflang is a signal, not a directive, implemented as <link rel="alternate" hreflang="xx" href="..."> in HTML, as an HTTP header, or as xhtml:link in an XML sitemap. When done correctly, it prevents duplicate content issues, improves international CTR, and boosts rankings in target countries.
Why hreflang is critical for International SEO
Without hreflang, Google may show the wrong language to users. For example, a German user might see your English page instead of your German page, increasing bounce rate and hurting conversions.
This tool solves the most common implementation failures:
- Reciprocal links: Every page in a cluster must link to all alternates including itself. Our generator creates a separate block for each URL automatically.
- Correct formatting: Language codes must be lowercase (
en) and region codes uppercase (US) with a hyphen:en-US, noten_US. The tool normalizes everything toen-USformat. - x-default handling: Generates the recommended
x-defaultfallback for unmatched languages or language selectors. - Multiple output methods: Get HTML tags for
<head>, HTTPLink:headers for PDFs and non-HTML files, and XML sitemap blocks ready for Google Search Console. - Validation: Detects duplicate hreflang values, duplicate URLs, mixed http/https, inconsistent trailing slashes, and missing self-references.
Perfect for SEOs, developers, content managers, and site owners running sites in multiple languages like en, de, fr, es, ja, or regional variants like en-US, en-GB, es-ES, es-MX, de-DE, de-AT.
Use it for Shopify, WordPress, Next.js, Webflow, or any custom CMS. All processing happens 100% client-side — your URLs never leave your browser.
How it works
1. Build your language cluster
Add each language/region version of the same page. Select the Language (ISO 639-1, e.g. en, de, fr) and optional Region (ISO 3166-1 alpha-2, e.g. US, DE, GB). Then paste the absolute URL like https://example.com/en-us/. The tool auto-composes the hreflang value as en-US.
You can also use Bulk Import — paste CSV lines like en-US, https://example.com/en-us/ or just a list of URLs and the tool will parse them.
2. Set your x-default
Enter your default fallback URL — usually your homepage, language selector, or global version. This is what Google shows when no other language matches. Toggle Include x-default on for best practice.
3. Choose generation options
- Include self-referencing tag: Recommended by Google. Each page should reference itself.
- Sort by hreflang: Alphabetical sorting for cleaner code.
- Reciprocal tags for every URL: When enabled, the tool generates a complete block for each page in your cluster. This is required — if page A links to page B, page B must link back to A.
4. Copy your preferred format
Use the format switcher:
- HTML: Paste inside
<head>of each page. Use the reciprocal view — copy the block labeledFor: https://...to that specific page. - HTTP Header: Use in
.htaccess, Nginx, or CDN config. Ideal for PDFs and images:Link: <url>; rel="alternate"; hreflang="de" - Sitemap XML: Copy the full
<urlset>withxmlns:xhtml. Each<url>contains all<xhtml:link rel="alternate">alternates. Submit to Search Console. - CSV / JSON: For spreadsheets, translation teams, or programmatic implementation.
Pro Tips
- Always use absolute URLs with
https:// - Keep trailing slashes consistent
- Never mix methods on the same URL (use either HTML or sitemap, not both)
- Validate after deployment with Google Search Console International Targeting report
Examples
US English, German and French cluster
Generate reciprocal HTML hreflang tags for three language versions with x-default fallback
English US vs UK targeting
Differentiate between US and UK English for regional search results
Sitemap XML for 4 languages
Create an XML sitemap with xhtml:link hreflang annotations for submission to Search Console
Frequently asked questions
What is hreflang and why is it important for SEO?
What is hreflang and why is it important for SEO?
Hreflang is an HTML attribute that tells search engines which language and regional targeting a page has. It looks like <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/" />. It is essential for international SEO because it helps Google show the German version to German users, the Spanish version to Spanish users, etc., which reduces bounce rate, avoids duplicate content issues, and improves conversions in local markets.
What is x-default and when should I use it?
What is x-default and when should I use it?
x-default is a special hreflang value that acts as a fallback for any language not explicitly listed. Google recommends it for your language selector page, homepage, or a global version. For example, if you target en-US and de-DE but a user from Japan visits, Google can show the x-default URL. You should include it in every cluster.
Where do I place hreflang tags — HTML, HTTP header, or sitemap?
Where do I place hreflang tags — HTML, HTTP header, or sitemap?
You have three options and must be consistent per URL. Use HTML <link> tags in <head> for most sites. Use HTTP Link: headers for non-HTML files like PDFs. Use XML sitemap with xhtml:link for large sites with many languages — this keeps your HTML clean and is easier to maintain. Our generator outputs all three formats from the same cluster.
Do hreflang tags need to be reciprocal?
Do hreflang tags need to be reciprocal?
Yes. Reciprocity is mandatory. If page A declares hreflang to page B, page B must declare hreflang back to page A and to itself. Otherwise Google may ignore the annotations. This tool has a reciprocal mode that generates a separate, complete block for each URL in your cluster so you can paste the correct block on each page.
Should I use en-US or en_US format?
Should I use en-US or en_US format?
Always use hyphen, never underscore. The correct BCP 47 format is language lowercase and region uppercase: en-US, de-DE, fr-CA, es-MX. Underscore format en_US is invalid and will be ignored. This generator automatically normalizes en_us to en-US and warns about invalid formats.
What is the difference between language and region targeting?
What is the difference between language and region targeting?
A language code alone like en, de, fr targets all speakers of that language globally. A language-region code like en-GB, en-US, de-AT, fr-CA targets speakers in a specific country. Use en if you have one English version for all, or use en-US + en-GB if you have distinct US and UK content with different pricing, spelling, or shipping.
Can I use hreflang with canonical tags?
Can I use hreflang with canonical tags?
Yes, and you should. Each language version should canonicalize to itself, not to another language. For example, the German page should have <link rel="canonical" href="https://example.com/de-de/"> plus hreflang tags to all alternates. Hreflang is not a replacement for canonical — they work together.
What happens if I make a mistake in my hreflang implementation?
What happens if I make a mistake in my hreflang implementation?
Common mistakes like missing return links, using relative URLs, using wrong codes, or inconsistent trailing slashes cause Google to ignore your hreflang cluster. The result is wrong language ranking, duplicate content issues, and wasted crawl budget. Use the built-in validation in this tool to catch duplicate hreflang values, duplicate URLs, mixed http/https, and missing self-references before you deploy.
Does this tool support bulk generation for many URLs?
Does this tool support bulk generation for many URLs?
Yes. Use Bulk Import to paste up to hundreds of lines in CSV format like en-US, https://example.com/en-us/ or TSV. It parses language codes and URLs, detects zh-Hans and zh-Hant, and builds the full reciprocal sitemap in seconds. You can then download the complete XML sitemap, CSV, or JSON for your dev team.
Related tools
More utilities you might find handy.
Alt Text Checker
Scan pasted HTML for images missing alt attributes
Canonical Tag Generator
Generate accurate canonical link tags for any URL to optimize SEO and prevent duplicate content issues.
Free UTM Link Builder - Create Campaign URLs Instantly
Build UTM-tagged URLs with validation, linting, and parse existing links to edit parameters. No sign-up required.