Skip to main content

Hreflang builder and validator

Turn locale=URL lines into hreflang link tags and detect invalid or duplicate entries.

  • Clipboard

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Hreflang tags

Was this tool useful?

How does this tool work?

This builder turns a list of language versions of a page into <link rel="alternate" hreflang> tags ready to paste into the <head>. Along the way it checks the language code format, duplicates and URL validity, to avoid the errors that stop search engines from matching the translations of the same page.

Each line follows the code=URL format. The code accepts a 2- or 3-letter language (en, fr, ast), optionally followed by a 2-letter region (en-GB, de-CH), or the special value x-default.

The URL must be absolute and start with http or https. The browser normalises it before it is written into the tag.

A code that is already used, even with different capitalisation (en and EN), is rejected: two versions cannot claim the same language. Rejected lines do not appear in the result and the status asks you to fix them.

The result lists one tag per version, in the order entered. The same block must appear on every page listed, including the page itself.

How to use this tool

  1. List the versions

    Enter one line per version in the form en=https://example.com/en/page.

  2. Add x-default if needed

    Give the page to show when no language matches, often a language picker or the English version.

  3. Check the status

    Valid configuration or an error message: fix the flagged lines.

  4. Copy the tags

    Paste the block into the <head> of every version listed.

Use cases

Launch a translated version

Declare the new language on every existing version of a page without writing the tags by hand.

Target countries sharing a language

Separate en-GB, en-US and en-AU when prices, delivery or legal notices differ by country.

Check a list before release

Spot a malformed code or a relative URL before it goes into a template.

Examples

Pricing page in three languages plus a Swiss version

Four tags are produced; the English version also serves as the default page.

Input

Localized versions:
fr=https://example.com/fr/tarifs
en=https://example.com/en/pricing
de-CH=https://example.com/ch/preise
x-default=https://example.com/en/pricing

Result

Valid configuration
<link rel="alternate" hreflang="fr" href="https://example.com/fr/tarifs" />
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing" />
<link rel="alternate" hreflang="de-CH" href="https://example.com/ch/preise" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/pricing" />

Duplicate language code

FR is rejected because fr already exists, so only the first line produces a tag.

Input

Localized versions:
fr=https://example.com/fr/
FR=https://example.com/fr-bis/

Result

Fix invalid lines or duplicate language codes.
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />

Tips and best practices

  • Each version must point to all the others and to itself: an annotation without a return link is ignored by Google.
  • Use ISO 639-1 codes for the language and ISO 3166-1 for the region: en-GB, not en-UK. The tool checks the format, not whether the code exists.
  • The URLs listed should be canonical, indexable and return a 200 status; avoid redirects.
  • On a large site, the same annotations can be declared in the XML sitemap or in an HTTP Link header, for example for PDF files.

Sources and references

Frequently asked questions

What is the hreflang attribute for?

It tells search engines that a page exists in other languages or for other countries, so they show each visitor the right version. It does not improve rankings; it prevents the wrong version from being shown.

What does x-default mean?

It is the page offered when the visitor’s language or country matches none of the listed versions, such as a language selection page or the international version.

Should I add the country as well as the language?

Only if the content changes between countries (currency, delivery, vocabulary). A language code alone, such as en, covers all English speakers. A country code alone, such as GB, is not valid.

Why is a line rejected?

The = separator is missing, the code does not match the language or language-region format, the code is already used, or the URL is not an absolute http or https address.

Does the tool check return links between pages?

No. It produces the block to place on each version but does not download the pages. Check on the live site that every version contains the same block.

Are my URLs sent to a server?

No. The tags are generated in your browser.

Related tools

Tools similar or complementary to this one.

Similar tools

Create SEO, Open Graph and Twitter/X tags for a web page.

Web & SEOFeaturedUse this tool

Create a clear robots.txt file to guide web crawlers.

Web & SEOFeaturedUse this tool
TutorialBest practicesBeginner

Optimize images for the Web without losing quality

Resize, compress and choose between WebP, AVIF and other formats with a practical workflow that reduces file size without unnecessary visual loss.

30 August 20264 min