Tool

hreflang & Canonical Validator

Audit hreflang, canonical, html lang, and og:locale on a localized page, or generate a reciprocal tag set for every language version. The HTML stays in this tab.

100% client-side: Your files never leave your browser. Live URLs are not fetched over the network.

0 B
Reference

How the validator works

Audit HTML reads one localized page and checks the tags that tell search engines which language versions exist: hreflang alternates, the canonical link, html lang, and og:locale. Paste a full document or only the head, or drop a file up to 2 MB. Add the page URL to turn on the self-reference check. Comments and script blocks are skipped, so a commented-out tag is not counted. The tool sits next to HTML Translate, and the wider workflow is covered in HTML translation best practices.

Generate Tags works the other way. Enter one absolute URL per language, choose the x-default page, and copy a head block for every version or the same set as an XML sitemap. Each block lists every alternate, including itself.

Common hreflang mistakes

MistakeWrongCorrectWhy
Country code as languagehreflang="jp"hreflang="ja"JP is the country. Japanese is ja in ISO 639-1.
UK instead of GBhreflang="en-UK"hreflang="en-GB"The ISO 3166-1 code for the United Kingdom is GB. A bare uk means Ukrainian.
Underscore separatorhreflang="en_US"hreflang="en-US"hreflang needs a hyphen. The underscore form belongs in og:locale.
Relative URLhref="/de/pricing/"href="https://example.com/de/pricing/"Alternates must be fully qualified URLs.
Canonical to EnglishGerman page → /en/ canonicalGerman page → /de/ canonicalA canonical to another language tells search engines to drop the translation.

How Self-Referencing Canonicals Work on Multilingual Sites

Each language version is its own canonical page. The German URL names itself as canonical, then lists every alternate, itself included, plus an x-default fallback. The English and French versions repeat the same alternate list with their own canonical.

<html lang="de">
<head>
  <link rel="canonical" href="https://example.com/de/pricing/">
  <link rel="alternate" hreflang="en" href="https://example.com/en/pricing/">
  <link rel="alternate" hreflang="de" href="https://example.com/de/pricing/">
  <link rel="alternate" hreflang="fr" href="https://example.com/fr/pricing/">
  <link rel="alternate" hreflang="x-default" href="https://example.com/en/pricing/">
  <meta property="og:locale" content="de_DE">
</head>

When the canonical names another language, the page is treated as a duplicate and its hreflang tags can be ignored. Keep the canonical, html lang, and self-referencing hreflang on the same language.

FAQ

When should a page set use hreflang="x-default"?

Use x-default for the page that serves visitors whose language is not in the set, usually a language selector or the English version. Declare it once, with the same URL on every language version.

Why does hreflang use a hyphen while og:locale uses an underscore?

hreflang follows BCP 47 language tags, so the separator is a hyphen: en-US, pt-BR, zh-Hant. The Open Graph protocol defines og:locale as language_TERRITORY, so en_US is correct there and wrong in hreflang.

Do Google and Bing read hreflang the same way?

Google uses hreflang to pick the language version shown in results. Bing treats hreflang as one signal next to html lang and the content-language meta tag. When all three agree, both engines get the same answer.

Should hreflang go in the HTML head or the XML sitemap?

Either works for Google. Pick one method per site so the sets cannot contradict each other. Head tags are easier to inspect page by page; a sitemap keeps large locale sets out of every page.

Does the validator fetch submitted URLs or upload pasted HTML?

No. Parsing and checks run in this browser tab, and no URL is requested. Reciprocal links on the other language versions are not crawled, so paste each version's head to check it.

More browser-side checks for localized HTML are listed in the tools hub.