Written by the Utiliby editorial team · Last updated October 14, 2026 · Rules and formulas reviewed October 2026
What this free hreflang tag generator does
If your site has the same page in more than one language or for more than one country, search engines need help to match each version to the right searcher. A visitor in Mexico should see the Spanish page written for Mexico, not the English page or the version for Spain. The signal that makes this possible is hreflang.
This free online hreflang tag generator turns a simple list into correct annotations. Enter a language, an optional region and the full address for each version. Add an x-default page if you have one. The tool writes HTML link tags, an XML sitemap with hreflang entries, or an HTTP Link header, and it checks the list for the mistakes that most often make hreflang fail. Everything runs in your browser, so nothing is uploaded.
How to use the generator
- List your versions. Add one row for each language or country version. Pick the language from the suggestions and add a region only when needed.
- Enter full addresses. Use the final, canonical address of each page, starting with https://.
- Add x-default. Enter the page for everyone else, such as a language picker.
- Choose a format. HTML tags, an XML sitemap or an HTTP header.
- Read the checks. Fix anything marked Fix, and consider each Tip.
- Publish the same set on every version. Copy the code or download the file.
You can also paste a list, one version per line, such as en-US https://example.com/en-us/, and add all the lines as rows in one step.
Language and region codes explained
A hreflang value has up to three parts. The language comes first and uses a two-letter ISO 639-1 code, such as en, es, de or ja. An optional script, such as Hans or Hant for Chinese, can follow. An optional region comes last and uses a two-letter ISO 3166-1 code, such as US, GB or MX. The pieces are joined with a hyphen, and the language is written in lowercase and the region in uppercase by convention.
| Goal | Value |
|---|---|
| English for anyone | en |
| English for the United States | en-US |
| English for the United Kingdom | en-GB |
| Spanish for Mexico | es-MX |
| Simplified Chinese | zh-Hans |
| Fallback for everyone else | x-default |
You cannot target a region alone. A value such as US with no language is not valid. The language is always required, and a region only narrows it.
The rules that make hreflang work
- Return links. If the English page lists the German page, the German page must list the English page. Search engines ignore one-way annotations.
- Self reference. Each page lists itself as well as its alternates.
- Full addresses. Use absolute addresses with the protocol. Relative paths are not valid.
- Canonical match. The address must be the page's own canonical address, and it should return a normal page, not a redirect.
- One method. Pick HTML, headers or a sitemap for a page. Mixing them is possible but harder to keep consistent.
- Same set everywhere. Every version carries the identical group of links.
Choosing between HTML tags, a sitemap and a header
HTML link tags go in the head of every page. They are easy to inspect and work well when the number of versions is small. The cost is that each page carries one line per version, so a site with 20 languages adds 20 lines to every page.
An XML sitemap moves the annotations out of your pages. Each address gets a url entry that lists all alternates with xhtml:link elements. This suits large sites and sites where the template is hard to edit. The sitemap must follow the usual sitemap limits, and you should submit it in Search Console.
An HTTP Link header is the only choice for files that have no head, such as PDFs. You set it on the server for each file. This tool outputs it as one header line that you can adapt to your server settings.
When to use x-default
X-default is not a language. It is a signal that a page is the right choice when no other version matches the visitor. Many sites point it at a language picker, a global home page or the version that serves most visitors. It is optional, but it is useful on sites with many versions because it gives search engines a clear fallback.
It follows the same rules as other versions: a full address, a return link and a place in every page's group.
Common hreflang mistakes
- Missing return links, the most common reason annotations are ignored.
- Wrong codes, such as en-UK instead of en-GB, or underscores instead of hyphens.
- Relative addresses, which are not accepted.
- Pointing to redirected or blocked pages, or pages with a noindex tag.
- Mixing http and https, or trailing-slash and no-slash versions of the same page.
- Using hreflang for near-duplicates only in one language, where a canonical tag is the right tool.
- Auto-translating without review, which gives a poor experience even if the tags are right.
Hreflang and the rest of international SEO
Hreflang tells search engines which page is for whom, but it works best with a clear site structure. Common choices are country-code domains, subdomains and subfolders. Subfolders are often the easiest to manage because they share one domain. Whatever structure you choose, keep the content of each version truly written for its audience, with local currency, units, contact details and spelling.
Hreflang does not replace the canonical tag, and it does not merge the ranking of different versions. Each version still needs good content, internal links and a place in the sitemap. For help with the head of each page, use the Meta Tag Generator and the Meta Robots Tag Generator on this site, and keep every version crawlable in robots.txt.
Testing your setup
After you publish, view the source of a few versions and confirm the same group of links appears on each. Open every address in the group and check it returns a normal page with no redirect. In Google Search Console, check the indexing reports for pages that were excluded and review any hreflang errors reported there. Search engines recrawl pages on their own schedule, so changes may take weeks to show.
Worked examples
Here are three common setups and how to enter them.
- One language, two countries: add en-US and en-GB with their own pages, plus x-default for the main page. The pages can differ in price, spelling and shipping details.
- Several languages with no country targeting: add en, es, de and fr, each with its own address, and set x-default to the language picker.
- One global English page and a few local ones: add en for the global page, es-MX and pt-BR for the local ones, and use the global page as x-default.
In each case, copy the same finished set into every version. If you add a new language later, update the set on all the existing pages as well, because every page must link to the new one.
Privacy and how it works
The tool builds the output and runs its checks in your browser. It does not visit the addresses you enter, so it cannot tell whether a page exists or links back. Nothing is uploaded, saved or logged. Print / save summary creates a report from your entries, and the rest of the page is not printed.
Frequently asked questions
What is hreflang?
Hreflang is an annotation that tells search engines which language and country each version of a page is for. It helps the right version appear for the right searcher.
How do I create hreflang tags for free?
Add a row for each version with its language, optional region and full address, add an x-default if you have one, and copy the tags. Paste the same set into the head of every version.
What is x-default?
It marks the page to show when none of your language versions fits the visitor, for example a language picker or your main international page.
Do I need a region code?
No. A language alone, such as es, is enough. Add a region, such as es-MX, only when you have separate pages for different countries that speak the same language.
Why is en-UK wrong?
The code for the United Kingdom is GB, so the correct tag is en-GB. The tool flags UK so you can fix it before publishing.
What are return tags?
If page A points to page B, page B must point back to page A. Every version also lists itself. Missing return links can make search engines ignore the annotations.
Where do I place hreflang tags?
Use one method per page: link tags in the head, an HTTP Link header, or entries in an XML sitemap. The tool produces all three formats.
Which format is best?
HTML tags are simple for small sites. Sitemaps suit large sites because they keep annotations out of the page code. HTTP headers help for files such as PDFs.
Should the address match the canonical URL?
Yes. Use the final address of each page, and make it the same address as the page's canonical tag. Hreflang pointing to a redirect or a non-canonical page is often ignored.
Can two codes point to the same page?
Yes, for example en-US and en-CA can share one English page. Each code should appear once, though, and a distinct page per audience is usually clearer.
How do I write Chinese versions?
Use zh-Hans for Simplified and zh-Hant for Traditional characters, and add a region such as zh-Hans-CN only if you need it. Plain zh is also accepted.
Does hreflang improve rankings?
It does not boost rankings. It helps the correct version appear for the right audience, which can reduce wrong-country visits and duplicate-looking pages.
Do Bing and Yandex use hreflang?
Google and Yandex read hreflang. Bing mostly relies on the content-language tag and other signals, so keep your language clear in the page itself too.
How do I check my hreflang setup?
Open the pages on the live site and view the source, then watch the indexing and international reports in Google Search Console. This tool checks the format, not your live pages.
What is the most common mistake?
Missing return links, wrong codes such as en-UK, relative addresses, and addresses that redirect. The checks above catch most format problems.
Is my data sent anywhere?
No. The generator runs in your browser and nothing you enter is uploaded.
What does Print / save summary include?
A short report with the format, the codes in use, the checks and the generated code. The rest of the page is left out.
Sources and further reading
- Google Search Central, Tell Google about localized versions of your page (developers.google.com), for the rules and formats.
- Google Search Central, Managing multi-regional and multilingual sites, for site structure options.
- ISO 639-1 language codes and ISO 3166-1 alpha-2 country codes, for the code lists.
- sitemaps.org Protocol, for the XML sitemap format.
- Yandex Webmaster documentation, for hreflang support.
- RFC 8288, Web Linking, for the Link header syntax.
Sources were consulted in October 2026. Standards and rules can change, so always check the official page for your situation.