Hreflang Generator
Tell search engines which language or regional version of a page to show. List each version as “code | URL” and the generator validates every code – ISO 639-1 language, optional script and ISO 3166-1 region – suggests fixes for common mistakes such as en-UK or en_US, checks for duplicates and missing x-default, and outputs the complete set as HTML link tags, XML sitemap entries with xhtml:link alternates, or a single HTTP Link header.
- Runs in your browser
- No sign-up
- Free to use
How to use Hreflang Generator
- List versions as “code | URL”, one per line.
- Add x-default for everyone else.
- Choose HTML, XML sitemap or header.
- Add the same set to every listed page.
Hreflang Generator features
Code validation
Languages, scripts and regions.
Fix suggestions
en-UK → en-GB, en_us → en-US.
x-default
Reminder when missing.
Three formats
HTML, sitemap, HTTP header.
Return links
Every page lists all versions.
Private
Runs in your browser; nothing is uploaded.
When to use Hreflang Generator
- Launching a site in several countries.
- Adding hreflang to a sitemap for large sites.
- Fixing hreflang errors from an audit.
- Setting hreflang on PDF files with headers.
Hreflang Generator FAQ
Why is en-UK wrong?
The ISO code for the United Kingdom is GB, so English for the UK is en-GB. Search engines ignore invalid codes.
What is x-default?
The page for users whose language or region does not match any version – often a language picker or the international page.
Do all pages need the tags?
Yes. Each version must list every version including itself. Tags that are not returned are ignored.
Tags or sitemap?
Either works. Sitemaps are easier to maintain for large sites; HTML tags are simpler for small ones.
How hreflang works
Hreflang annotations link equivalent pages in different languages or for different regions. They help search engines show a German user the German page and a Swiss user the Swiss-German one, and stop the versions from being treated as duplicates.
The most common errors are invalid codes, missing return links and pointing to URLs that redirect or are not canonical. The generator catches the first and reminds you of the others.
Language codes come before regions; a region on its own is not valid. Use a plain language code for versions that serve all speakers.
Privacy: everything on this page runs in your browser. What you type or paste is not uploaded, stored or logged, and the result is generated on your device, so you can safely work with unpublished content, client data or drafts.
Tip: the result updates as you type, so you can try variations quickly. Copy the output with one click or download it as a file, and keep a copy of your input if you want to come back later – nothing is saved between visits.
Who it is for: the tool is built for site owners, marketers, writers and developers alike. You do not need to install anything or create an account, it works on phones as well as on desktop computers, and the results are plain text you can paste into any CMS, spreadsheet, code editor or ticket.
Accuracy: the rules used here are documented on the page and follow the published guidelines of the major search engines and web standards. Where a result is an approximation or a rule of thumb rather than an official limit, the page says so, so you can decide how much weight to give it.
Good practice: generated markup and files only help when they match the real page. Publish them together with the visible content they describe, test the page with the official tools from the search engines, and update the markup whenever the page changes.