Hreflang Generator
Tell Google which language or regional version of a page to show each user. Enter your versions and get valid hreflang tags for the HTML <head>, an XML sitemap or HTTP headers — with every language and region code checked against the ISO standards.
What Is hreflang?
An annotation that links the language and regional versions of the same page together.
If your page exists in several languages — or in one language for several countries, like English for the US and the UK — hreflang tells Google about all the versions so it can show each user the right one. Each version lists itself and every other version with a language code, plus an optional x-default fallback.
Codes use an ISO 639-1 language (en, hi, as), optionally followed by an ISO 3166-1 region (en-GB, hi-IN) or a script (zh-Hant). Common mistakes — en-UK instead of en-GB, a country code on its own like gb, or es-419, which Google doesn't support — are caught as you type.
You can deliver the annotations three ways: <link> tags in the <head> of each page, <xhtml:link> entries in an XML sitemap, or an HTTP Link header (handy for PDFs). Pick one method — they all mean the same thing.
Annotations only count when they're reciprocal: if page A points to page B, page B must point back to A. Google ignores links that aren't confirmed by the other page. That's why the output is the same for every version — copy it to all of them.
Google's hreflang Rules
What makes hreflang annotations valid.
Reciprocal and self-referencing
Each version lists itself and all the others. If two pages don't point to each other, the annotation is ignored.
Valid codes
Language in ISO 639-1, optional region in ISO 3166-1 alpha-2 (GB, not UK), or a script like Hant. Region codes alone and codes like es-419 aren't supported.
Full URLs
Every URL must be absolute, including https://. Versions may be on different domains.
x-default
The fallback for languages you don't list — ideal for a language-selector or international home page.
How to Use the Hreflang Generator
Get your result in under ten seconds.
List the versions
Add each language or regional version of the page with its code and full URL.
Add a fallback
Set the x-default URL for everyone else — usually your main or language-selector page.
Copy to every version
Choose HTML, Sitemap or HTTP, then add the same output to all the versions.
Why Use the Hreflang Generator on Developers Web Tools
Fast, accurate and private — built for developers.
ISO code checks
Every language, script and region code is validated against the official lists.
Fix suggestions
en-UK → en-GB, gb → a language code, es-419 → a supported code.
Three formats
HTML link tags, XML sitemap with xhtml:link, or an HTTP Link header.
Readable preview
See which language and country each version targets, in plain words.
Escaped output
URLs are escaped correctly for HTML and XML.
Private
Runs entirely in your browser.
Frequently Asked Questions
en-GB. The ISO 3166-1 region code for the United Kingdom is GB — “UK” isn't valid and Google will ignore en-UK.
Yes. Each page lists every version, including itself. The output of this tool already includes all versions, so the same code goes on every page.
It tells Google which page to show users whose language or region doesn't match any version you listed. It's optional but recommended, especially for language-selector or international home pages.
No. hreflang always starts with a language. To target Belgium you'd use nl-BE, fr-BE or de-BE — “be” on its own means the Belarusian language.
Any one of them. HTML tags are simplest for small sites. Sitemaps are easier to maintain for large sites because nothing changes in the pages. HTTP headers are for non-HTML files like PDFs.
Yes. Google allows alternates on different domains, such as example.de and example.fr, as long as each page links back.
Only in your browser's localStorage. Press Reset to clear it.