Skip to content
Surfilby Adam Hafez
Free tool

Hreflang tag generator and checker

Hreflang tag generator: build link rel=alternate hreflang tags for localized URLs and check codes, self-references and x-default. Free, runs in browser.

Runs entirely in your browser. Nothing you enter is uploaded, logged or stored.

    Key takeaways

    • Google says each language version must list itself as well as all other language versions, and ignores tags when two pages do not both point to each other.
    • The same set of link tags goes in the head of every version of the page, so the block this tool builds is pasted unchanged on each one.
    • A language and region code such as en-US may point at only one URL within a set.
    • Google accepts hreflang codes in either case, but this tool expects the conventional form, a lowercase language and an uppercase region.
    • The x-default value is optional and marks a fallback page for visitors whose language matches none of the listed versions.

    What it takes

    • A URL for each localized version of a page
    • The language code for each URL, with an optional region
    • An optional x-default row for the language selector or fallback page

    More tools

    All of them free, all of them browser-only.

    Browse the tools

    How to use it

    1. 1Add a row for every localized URLUse the exact URL Google would index for that language, including the protocol and any trailing slash you actually publish.
    2. 2Set the language code for each rowUse a lowercase ISO 639-1 code such as en or es, and add a region after a hyphen only when the content genuinely differs by region, such as en-US versus en-GB.
    3. 3Add every URL as a row on itself tooReciprocity means each URL needs a row pointing at its own language, not only rows pointing at the other versions.
    4. 4Add x-default if you have a language selector or fallbackThis is optional, but Google recommends it so visitors whose browser language matches nothing in the set land somewhere useful.
    5. 5Read the warningsThe tool flags missing self-references, duplicate codes pointing at different URLs, and invalid code formats before you ship the tags.
    6. 6Copy and pastePaste the generated link tags into the head of every page in the set, not just one of them.

    What the generator checks

    Enter one row per localized URL with its code, and the tool writes one <link rel="alternate" hreflang="..." href="..." /> line per row. Google says the set “is identical for every version of the page”, so the same block goes in the head of each version. The tool then runs four checks and lists anything it finds:

    • Code format. A two-letter lowercase language, optionally a hyphen and a two-letter uppercase region, or x-default. Google’s codes are ISO 639-1 languages and ISO 3166-1 Alpha 2 regions.
    • A code of its own for every URL. Google says each version “must list itself as well as all other language versions”. When there are two or more URLs, each needs at least one code that no other URL uses.
    • One URL per code. A code that points at two URLs is flagged with the count.
    • x-default. With two or more URLs and no x-default row, the tool adds a reminder.

    How to read the results

    Every finding appears in the issue list with its row number or URL. “No issues found in this set” means all four checks passed. The tags update as you type, and “Copy the tags” puts the block on your clipboard.

    The x-default reminder needs no action if you have no language selector or catch-all page. Treat the code format warning as a style fix: Google says the hreflang value is case-insensitive, so en-gb works in Search. The tool still expects en-GB, the ISO 3166-1 Alpha 2 convention.

    A URL whose only row is x-default, such as a separate country selector page, is flagged as having no code of its own. If that page carries the same tag set as the others, it lists itself through x-default, so you can ignore that finding.

    Worked example

    The tool loads with three rows: en for https://example.com/, es for https://example.com/es/ and es-MX for https://example.com/es-mx/. It builds three link tags and reports one issue: “No x-default set. Not required, but Google recommends it as a fallback for users whose language does not match any version.”

    Change the third row’s code from es-MX to es and the list grows to four issues. Both Spanish URLs are reported as having no hreflang row pointing back to their own language, since each one’s only code is now shared, the x-default reminder stays, and “es” points to 2 different URLs.

    Common mistakes it catches

    • Country codes on their own. Google’s example: be is Belarusian, not Belgium.
    • Region-first or malformed codes, such as US-en or english.
    • Two URLs sharing one code within the same set.
    • A URL with no code of its own.

    The tool cannot fetch the pages, so it cannot confirm that the live tags are on every page or that return links exist. It also checks format, not meaning: en-UK passes, though Google says reserved codes such as UK have no effect and the right code is GB. Script codes such as zh-Hant, which Google supports, are flagged. Add those by hand.

    Sources

    1. 1.Tell Google about localized versions of your page - Google Search CentralPrimary

    Common questions

    Does every page need a hreflang tag pointing to itself?

    Yes. Google says each language version must list itself as well as all other language versions, and the set of links is identical on every version of the page.

    What happens if the return links are missing?

    Google says that if two pages do not both point to each other, the tags are ignored. If some languages are missing on some pages, Google still processes the pairs that do point to each other.

    Is x-default required?

    No. Google recommends it as the fallback for users whose language settings match none of your versions, and says it was designed for language selector pages.

    Why is en-gb flagged when Google accepts it?

    Google says hreflang values are case-insensitive. This tool expects the conventional casing, a lowercase language and an uppercase region, so write en-GB to clear the warning.

    Can I target a country without a language?

    No. Google says you cannot specify the country code by itself, because the first code is always the language. Use a pair such as fr-BE, not be.

    Tools

    Hreflang XML sitemap generator

    Hreflang sitemap generator: turn language codes and URLs into sitemap XML with xhtml:link alternates, and check codes and URLs. Free, runs in your browser.