Hreflang Tag Generator

Generate hreflang link tags for a multilingual page from a list of locale and URL pairs, with an optional x-default and a self-referencing tag.

Loading tool…

Hreflang Tag GeneratorHreflang Tag Generator turns a list of locale-and-URL pairs into the rel="alternate" hreflang link tags you paste into the head section of every language version of a page. Add a row for each locale, optionally include an x-default fallback and a self-referencing tag, and copy the ready-to-use block. Everything is built in your browser, so your URLs are never uploaded to our servers.

What is Hreflang Tag Generator?

Hreflang tags tell search engines which URL serves which language or region, so Google and Yandex show the right version to each user and avoid treating translations as duplicate content. SEO specialists, localization teams, and developers add them when a site has the same page in several languages — for example /en/, /ja/, and /es/. This tool builds the standard rel="alternate" hreflang="…" link tags: you add one row per locale with its hreflang code (like en, en-US, or ja) and its absolute URL, and the output updates live as you type. Use the Add locale button to append rows and Remove to drop one. In the settings you can toggle the self-referencing tag (each page should point to itself) and the x-default tag, which names the page shown when no language matches; if you leave the x-default URL blank it falls back to the self-referencing URL.

How to use Hreflang Tag Generator

  1. Enter the locale code and absolute URL of the current page in the self-referencing fields (for example en and https://example.com/en/).
  2. Add a row for each alternate language: type its hreflang code (like ja or es-MX) and its full URL.
  3. Use Add locale to append more rows, or Remove to delete one you do not need.
  4. Open settings to toggle the self-referencing tag and the x-default tag on or off.
  5. Optionally set a dedicated x-default URL; leave it blank to reuse the self-referencing URL.
  6. Copy the generated link tags and paste them into the <head> of every language version of the page.

Examples

Two languages with x-default

Input

self: en https://example.com/en/
row: ja https://example.com/ja/

Output

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

Regional targeting

Input

row: en-US https://example.com/us/
row: en-GB https://example.com/uk/

Output

<link rel="alternate" hreflang="en-US" href="https://example.com/us/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />

Special characters are escaped

Input

row: fr https://example.com/?a=1&b=2

Output

<link rel="alternate" hreflang="fr" href="https://example.com/?a=1&amp;b=2" />

Frequently asked questions

What does this tool generate?
It generates rel="alternate" hreflang link tags from the locale-and-URL pairs you enter. Each filled-in row becomes one <link> tag; it can also add a self-referencing tag for the current page and an x-default tag, so you get a complete block ready to paste into the page <head>.
What is the x-default tag for?
x-default marks the page a search engine should show when none of the listed languages or regions match the user. You can give it its own URL, or leave the x-default URL blank and the tool reuses the self-referencing URL. Toggle it off in settings if you do not want one.
Do I need a self-referencing tag?
Google recommends that every language version include a hreflang tag pointing to itself, plus tags for all the alternates. This tool adds that self-referencing tag from the locale and URL of the current page; you can turn it off in settings if you prefer to add it manually.
What format should the hreflang code use?
Use an ISO 639-1 language code, optionally with an ISO 3166-1 region — for example en, ja, es-MX, or zh-Hant. The tool writes whatever code you type verbatim, so check that it is a valid value; the URL should be an absolute address starting with https://.
Is my data sent to a server?
No. The tags are built entirely in your browser with JavaScript. Nothing you type — including unpublished URLs — is uploaded, stored, or sent anywhere, so it is safe to use on private or pre-launch pages.

Related tools