hreflang is easy to describe and easy to get wrong: every version has to list every other version and itself, with valid language and country codes and absolute URLs, or search engines quietly ignore it. This generator validates each tag against the ISO 639-1 language and ISO 3166-1 country lists, flags classic mistakes like en-UK, duplicate tags, and relative URLs, and then writes the complete set for you — one block per page as HTML <link> elements, as XML sitemap entries, or as an HTTP Link header for PDFs.
Everything runs in your browser; nothing you enter is uploaded. hreflang works alongside the rest of your head markup, so pair it with the meta tag generator for titles and descriptions, put the alternates into a full sitemap with the sitemap generator, and make sure crawlers can reach every language folder with the robots.txt generator.
Frequently asked questions
What is hreflang and when do I need it?
hreflang is an annotation that tells search engines which language or regional version of a page to show a given searcher. You need it when the same content exists in more than one language (English and French), or in one language for different countries (en-US and en-GB with different prices or spelling). Without it, Google may rank the wrong version in a country or treat near-identical regional pages as duplicates. hreflang is a hint, not a directive — it does not redirect anyone — so keep a visible language switcher too. Bing mostly ignores hreflang and relies on the content-language meta tag and other signals instead.
Why does every page have to list itself (self-referencing and reciprocity)?
Google only trusts an hreflang pair when both pages confirm it. If your English page points to the French page, the French page must point back to the English page — otherwise the annotation is ignored. The simplest way to guarantee that is to put the exact same, complete set of tags on every version, including a tag for the page itself. That is why the HTML output repeats the full block once per page. The most common hreflang failure in audits is a missing return link after someone adds a new language to one page but forgets the others, so regenerate and redeploy the whole set whenever a version is added or removed.
What is x-default?
x-default is the version shown to searchers whose language or region does not match any of your tags — for example a Japanese speaker when you only have English and French. Point it at a language-selector page or at your main, most general version (often the same URL as your plain "en" page, which is perfectly valid). It is optional, but recommended by Google for any site that serves multiple languages. Like every other tag, the x-default line must appear in the set on every page, and there can only be one x-default per set.
Which language and region codes are valid?
Google expects an ISO 639-1 two-letter language code, optionally followed by an ISO 3166-1 alpha-2 country code: en, en-GB, pt-BR. You can also add a script for languages written in more than one, such as zh-Hant-TW or sr-Latn. A country on its own is never valid — "US" or "GB" needs a language first. Classic mistakes this tool catches: en-UK (the United Kingdom is GB), jp instead of ja for Japanese, cn instead of zh for Chinese, underscores like en_US, and three-letter codes such as fil. Codes are case-insensitive, but the tool outputs the conventional casing (en-GB, zh-Hant).
Should I use HTML tags, the sitemap, or HTTP headers?
All three are equivalent to Google; pick one method per page and do not mix them, because conflicting sets are a common source of errors. HTML link tags are easiest for small sites and CMS templates. An XML sitemap is better for large sites, since you manage every alternate in one file without touching page templates and it does not bloat your HTML. HTTP Link headers are the only option for non-HTML files such as PDFs, because they have no head section; set them in your server, CDN, or edge config so each file version returns the same header.
Does this tool check my live pages?
No. It validates the tags and URLs you enter and generates correct markup, but it does not fetch your site, so it cannot confirm that the tags are actually deployed, that the URLs return 200, or that each page links back. After deploying, spot-check a few versions with your browser’s view-source, and check that every URL is the canonical version of its page — hreflang pointing at a redirecting or non-canonical URL is ignored. Everything you type stays in your browser; nothing is sent to a server.