My Tool Studio
SEO

Hreflang Tag Generator

This hreflang generator builds the tags that tell Google which language or country version of a page to show each visitor. Pick a language and an optional country from ISO lists, or type a code such as es-MX, then add the full URL of that version. Reorder rows with the arrow buttons. For many pages, paste or upload a CSV with one column per language and one row per page set. Output comes as HTML link tags, an XML sitemap or HTTP Link headers, ready to copy or download. The tool flags invalid codes like en-UK, relative URLs, duplicates and a missing x-default. A live checker reads a published page and confirms every alternate links back.

Always freeNo sign upRuns in your browser

Pick a language and, if the page targets one country, a country. Or type the code yourself.

Codes, URLs and x-default look correct.

<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Every version in a set gets the same block, including a link to itself.

How to use

01

Add each version, or upload a CSV

In Build tags, pick a language and country or type the code, and paste the full URL of each version. Keep an x-default row for your fallback page. For many pages, use Bulk from CSV with a header row of codes.

02

Fix the warnings and pick an output

Fix any warning under the rows, such as an unknown code or a URL without https://. Then choose HTML link tags, XML sitemap, or HTTP Link header for PDFs and other files.

03

Copy, publish, then check it live

Press Copy or Download and add the output to every version of the page, or to your sitemap. Once live, open Check a live page to confirm each alternate returns a link to the others.

Why Hreflang Tag Generator

Common hreflang code mistakes

Most hreflang errors are small typos in the codes. The generator warns about each of the mistakes below, which are the ones seen most often in audits. Google ignores an annotation it cannot read, so one bad code can quietly drop a version from the set without any error on the page itself.

WrongRightWhy
en-UKen-GBThe ISO country code for the United Kingdom is GB
jpjajp is a country code; the language code for Japanese is ja
en_USen-UShreflang uses a hyphen, not an underscore
es-419es-MX, es-AR and so onGoogle only supports two-letter country codes, not numeric regions
en-EUen-IE, en-DE and so onEU is not a country; list each country or use en
USen-USA country alone is not valid; the language comes first
/es/https://example.com/es/URLs must be absolute

Common questions

What format do hreflang language codes use?
A two-letter ISO 639-1 language code, optionally followed by a hyphen and a two-letter ISO 3166-1 country code. So es targets Spanish speakers everywhere, while es-MX targets Spanish speakers in Mexico. A country on its own, like MX, is not valid, and the generator flags it.
Why do I need an x-default row in the hreflang set?
The x-default entry names the page for visitors whose language matches none of your versions, often a global page or a language picker. Google recommends it. Without one, those visitors get whichever version Google thinks is closest.
Do hreflang tags have to appear on every language version?
Yes. Each page in the set must carry the complete list, including itself, and every pair must point at each other. If the Spanish page lists the English one but not the reverse, the return link is missing and Google may ignore the pair.
Can hreflang target the same language in two countries?
Yes, that is one of its main uses. An en-GB row and an en-US row let you show prices in pounds to UK visitors and dollars to US visitors with otherwise similar content. hreflang tells Google these are regional versions, not competing duplicates.
Should the URLs in each hreflang row be absolute?
Yes, full URLs with the protocol and domain, like the https://example.com/es/ sample in the tool. The generator warns about any URL that does not start with http:// or https://. Each URL should also be the canonical, indexable version of that page.
Does the hreflang generator check return links on my live site?
Yes, in the Check a live page tab. It reads the hreflang tags in the page's HTML, validates the codes, x-default and self-reference, then opens up to 15 alternates and reports whether each one links back and whether its canonical points elsewhere. It reads HTML tags only, so sets that live in a sitemap or HTTP headers are not checked there.
Can I put hreflang in a sitemap instead of the head?
Yes. Google accepts hreflang in the HTML head, in an XML sitemap using xhtml:link elements, or in HTTP Link headers for files such as PDFs. Pick the format under Output: the sitemap option writes one url entry per version, each listing every alternate. Use one method for a set of pages so there is a single source of truth.
How do I build hreflang for hundreds of pages at once?
Use Bulk from CSV. The first row lists the codes, for example en, en-GB, de, x-default, and every row after it lists one page in each language. Paste from a spreadsheet or upload a .csv file; leave a cell empty when a page has no version in that language. The output groups the tags per page set, or builds one sitemap for all of them.
Why is Google ignoring my hreflang annotations?
The usual causes are missing return links, URLs that redirect or are not the canonical version, and invalid codes like en-UK instead of en-GB. Fix the codes here first, then make sure every listed page lists every other page.

More SEO tools

View all