PBNLinksHub
Get Started
Technical SEO ToolsRuns in your browserFree · no sign-up

Hreflang Generator & Validator

Generate hreflang annotations for your language and regional versions in three formats — HTML, XML sitemap or HTTP header — or paste a page to validate the tags it already has: codes, x-default, self-reference, duplicates and URLs.

Hreflang Generator & Validator
Language versions

Code: a language (en), optionally with a region (en-GB), or x-default. URLs must be absolute.

HTML <link> tags

How to use the Hreflang Generator & Validator

  1. List each version

    Add one row per language or region with its code and absolute URL, plus an optional x-default.

  2. Choose a format

    HTML tags for the head of each page, sitemap entries for large sites, or an HTTP Link header for PDFs and other files.

  3. Copy to every version

    The same full set of annotations goes on every page in the group, including a reference to itself.

  4. Validate

    Use Validate a page to check what's actually published.

What it checks

Code format
Each value must follow the language[-Script][-REGION] pattern: two or three letters, an optional four-letter script and an optional two-letter or three-digit region — for example en, en-GB, en-US, zh-Hant or es-419.
Common mistakes
Underscores (en_GB), a handful of well-known slips such as en-UK instead of en-GB, and two-letter values that may be a country code rather than a language.
x-default
Whether a fallback is declared, and that it appears only once.
Duplicates and conflicts
The same code used for different URLs, and one URL used for several codes.
URLs
Absolute http(s) URLs; relative, empty or fragment URLs are flagged.
Self-reference
When you provide the page URL, whether the page lists itself.

Interpreting the results

In Generate mode the output updates as you type, and notes flag invalid codes or URLs before you copy anything. In Validate mode each annotation is listed with its code, URL and any problem, followed by a summary of set-level issues such as a missing self-reference or x-default.

Hreflang must be reciprocal: if page A lists page B, page B must list page A. Search engines may ignore annotations that aren't confirmed by the other pages. This tool checks one page at a time, so validate each version, or generate the set once and use it everywhere.

Detected marks facts read directly from what you provided. Guidance marks general recommendations based on those facts — rules of thumb, not guarantees or search engine requirements.

Practical guidance

Use language-only codes unless the content genuinely differs by region. en is right for one English version; en-GB and en-US make sense when prices, spelling or delivery differ. The most common mistakes are en-UK (the ISO code is GB), country-only codes like de-DE written as DE, and forgetting that every page must reference itself.

Hreflang works alongside canonicals, not instead of them: each language version should canonicalise to itself. Check that with the Canonical URL Checker, and use the XML Sitemap Validator if you put hreflang in sitemaps.

For country-targeted campaigns, links from sites relevant to the target market support the regional version you want to rank — the idea behind our PBN countries page. Our guide to link relevance explains why geography and topic both matter.

Limitations

  • Validation covers one page's annotations. It doesn't fetch the other versions to confirm return links.
  • Codes are checked by format and for a few common mistakes, not against the full official registries — a well-formed but non-existent code would pass.
  • It can't tell whether the page content actually matches the declared language.

Frequently asked questions

Do I need x-default?

It's recommended when you have a fallback page — for example a language selector or a global English version — for users who don't match any listed language.

HTML, sitemap or header — which is best?

They're equivalent. HTML is simplest for small sites; sitemaps scale better for many pages; headers are the only option for non-HTML files.

Is en-UK valid?

No. The ISO 3166 code for the United Kingdom is GB, so use en-GB.

Is anything uploaded?

No. Everything runs in your browser.

More in Technical SEO Tools · All 25 free SEO tools