Hreflang tag generator

This hreflang tag generator checks a list of language versions, one hreflang code and URL per line, then writes the annotations in the format you choose: HTML link tags, an XML sitemap with alternates, or HTTP Link headers. It flags invalid ISO codes, region-only codes, en-uk, duplicates and repeated URLs before you publish anything.

Formats
HTML, XML sitemap, HTTP headers
Runs
in your browser
Cost
free, no signup

Your language versions. Nothing you type leaves this page.

List every version in the cluster, including the page you are working on. Use a hyphen, not an underscore: en-gb, not en_GB.
The page for users whose language matches none of the versions, often a language picker.
Output format

Codes are checked against ISO 639-1 languages and ISO 3166-1 regions. Pick one output format and use only that method for the cluster.

Checks on your list

Before a run, these are the rules the output follows. After a run, each row is one line you entered

  1. Not runValid language and region codes—

    Why it mattersGoogle supports ISO 639-1 language codes, optionally followed by an ISO 3166-1 Alpha 2 region, such as de or en-gb. Common slips are en-uk (the United Kingdom is gb), a region on its own such as gb, and an underscore as in en_GB.

    How to fixStart every code with the language, then add a region only if the page is aimed at one country. Unknown codes are errors, en_GB is rewritten as en-gb with a warning, and a four-letter script subtag such as zh-hant is accepted.

  2. Not runEach page lists itself—

    Why it mattersGoogle's documentation says each language version must list itself as well as all other versions. It looks redundant, so it is often left out.

    How to fixInclude the page you are working on as one of the lines. The generator writes one block containing every line, so each page lists itself if the block goes on every page.

  3. Not runx-default in its own field—

    Why it mattersx-default tells Google which page to show when a visitor's language or region matches none of your versions. It is optional, but useful for a language picker.

    How to fixEnter the fallback URL in the x-default field rather than as a line. A missing x-default is a warning; one typed as a line is an error.

  4. Not runReturn links on every version—

    Why it mattersIf two pages do not both point to each other, Google's documentation says the tags will be ignored. Return links break when one locale is updated and the others are not.

    How to fixPublish the identical block on every page in the list, and update all of them whenever you add or remove a version. Then run each locale through the Hreflang Validator to confirm the live pages link back.

  5. Not runFully qualified URLs, one per code—

    Why it mattersGoogle requires fully qualified alternate URLs, including the protocol, so /de/ on its own is not accepted.

    How to fixWrite every URL in full, starting with https://, exactly as the page is served and canonicalised. A relative URL stops the run. A repeated code is an error; the same URL under two codes is a warning.

Your hreflang output

The block to publish, in the format you picked, with copy and download buttons

Nothing to show yet. After you generate, this shows the full output: <link rel="alternate" hreflang> tags, a sitemap with xhtml:link alternates, or a Link: header, ready to copy or download, plus a link to check the live pages.

What each result means

The generator does not score your list. It gives every line a status and writes the output anyway, so read the statuses before you copy the block. A few problems stop the run completely.

What the generator reports for each kind of input
InputStatusWhat happens
Valid code and absolute URLPassWritten to the output, code in lower case.
Unknown language or region, such as en-ukErrorStill written to the output, so fix it first. The UK is gb.
Region on its own, such as gbErrorSuggests a language prefix, such as en-gb.
Underscore, such as en_GBWarningRewritten as en-gb.
The same code twiceErrorEach code may point to one URL only.
The same URL under two codesWarningUsually a copy-paste slip.
x-default typed as a lineErrorMove it to the x-default field.
No x-defaultWarningOptional, but recommended.
Only one versionWarninghreflang needs two or more.
Relative URL, or a line that is not code then URLStops the runA message names the line. Nothing is generated.
Readyno errors

Safe to publish; still read any warnings.

Errors to fix1 or more

The output contains the bad lines. Fix them and generate again.

Stoppedno output

A line is malformed or a URL is not absolute.

The checks run on what you type. The generator does not fetch any URL, so it cannot tell whether a page exists, returns 200, canonicalises to itself or is really a translation. The script subtag check accepts any four letters and does not test them against ISO 15924. Rules are from Google's guide to localised versions of your pages.

How to generate hreflang for a cluster

Work from a complete list of versions. Every translation or regional variant of the same content belongs on it, once.

  1. Step 1

    List every version, one per line

    Type the hreflang code, a space, then the full URL, for example en-gb https://example.com/uk/. Include the page you are working on. Use the URL each page canonicalises to.

  2. Step 2

    Add x-default if you have a fallback

    Put your language picker or global page in the x-default field, not as a line. Leave it empty if no page serves that role.

  3. Step 3

    Choose one format

    HTML tags for ordinary pages, XML sitemap if you manage hreflang in the sitemap, HTTP headers for PDFs and other files that have no HTML head.

  4. Step 4

    Fix every line marked as an error

    Each row in the results is one line you entered. Lines with errors are still written into the output, so correct them and generate again before copying.

  5. Step 5

    Publish everywhere, then validate

    Put the same block on every page in the list. Then check the live pages with the Hreflang Validator, starting from more than one locale.

Three formats, pick one

Google's documentation describes three ways to declare language versions, HTML link elements, HTTP headers and the XML sitemap, and treats them as equivalent. Use the one that fits how your site is built, and only one: two methods side by side drift apart.

Whichever format you pick, the same rule applies: every version lists itself and every other version. The generator builds the full set once, so the block for the UK page is identical to the block for the German page. If you find yourself editing the block per page, something has gone wrong.

The three output formats and when to use each
FormatWhat you getUse it when
HTML tagsOne <link rel="alternate"> tag per version, plus x-default.You can edit the page head. Put the block in the head of every page listed.
XML sitemapOne <url> per version, each with an xhtml:link for every version and x-default.Templates are hard to change, or you want the annotations in one file.
HTTP headersOne Link: header listing every version and its hreflang.The file is not HTML, such as a PDF. Send the same header for every version.

What the generator does

  • Checks each code against ISO 639-1 languages and ISO 3166-1 Alpha 2 regions
  • Catches region-only codes, en-uk, underscores, duplicate codes and repeated URLs
  • Writes HTML tags, a sitemap or a Link header, ready to copy or download
  • Runs in your browser; your list is not sent to MoxSEO

What it does not do

  • Fetch your pages, so it cannot see status codes, redirects or canonical tags
  • Check that the versions are real translations of the same content
  • Remove lines with errors from the output; you fix them and generate again
  • Publish anything or confirm the tags are live

Where hreflang goes wrong after it is generated

Most hreflang problems start after the tags are written. A new French page goes live with the block, but the other versions are never updated to point to it, so the return links are missing. Or the site moves to new URLs and the hreflang still lists the old ones, which now redirect.

So once you have published, check with the Hreflang Validator, which reads the live HTML of a page and fetches its alternates to confirm the return links. For the sitemap format, check the file with the XML Sitemap Validator, and confirm each locale is indexable with the On-Page and Indexability Audit.

Correct hreflang helps Google show the right version to the right audience. It does not make a version rank in a market where it would not rank anyway. Building visibility in a new country is a separate job, covered by our international SEO work.

Planning hreflang for a large or growing site?

We can map the language and region versions, choose the right method for your stack and check the live cluster end to end.

Hreflang generation, answered plainly

Short, standalone answers. Email editorial@moxseo.com if any of them is wrong.

What does the Hreflang Tag Generator do?

It takes a list of language versions, one hreflang code and full URL per line, checks each line, and writes the annotations as HTML link tags, an XML sitemap with xhtml:link alternates, or an HTTP Link header. It runs in your browser and does not fetch your pages.

Which hreflang format should I use?

Google treats HTML tags, HTTP headers and the XML sitemap as equivalent, so pick the one that fits your site and use only that one. HTTP headers are for files with no HTML head, such as PDFs.

Is en-uk a valid hreflang code?

No. Regions use ISO 3166-1 Alpha 2 codes, and the United Kingdom is GB, so the correct value is en-gb. The generator marks en-uk as an error and tells you to use en-gb. On its own, uk is the ISO 639-1 code for Ukrainian, so it passes as a language. A region alone, such as gb, is an error: an hreflang value must start with a language.

Do I need x-default?

It is optional. x-default names the page for visitors whose language matches none of your versions, usually a language picker. The generator warns when it is missing but still writes the output. Enter it in its own field, not as a line.

Why does the output still contain a line marked as an error?

The generator writes every line so you can see the whole cluster. Do not publish a line marked as an error: correct it and generate again. Relative URLs and lines that are not a code followed by a URL stop the run instead, with a message naming the line.

Is my list stored or sent anywhere?

No. The checks and the output run in your browser, and nothing you type is sent to MoxSEO. The tool is free with no signup. To check pages after you publish, use the Hreflang Validator, which does fetch the URLs you give it.

All 23 free tools

Clean tags get the right page served.
Authority gets it found.

Keeping a cluster correct as the site grows is where hreflang slips. Book a free 30-minute call with Sakshi Kumari or Ashish Khan, or see our international SEO services.

A call is not an engagement. We never guarantee rankings or AI citations.