Hreflang Tag Generator & Validator
Build a complete hreflang cluster for the language and regional versions of a page, then export it as HTML <link> tags, XML sitemap annotations or an HTTP Link header — and check annotations you already use. Everything runs in your browser: nothing is uploaded, and the tool never fetches your pages.
- Free to use
- No account required
- Runs in your browser
Hreflang Tag Generator & Validator
Was this tool helpful?
Good to know
- Useful for
- SEO specialists, developers, agencies and owners of multilingual or multi-regional websites who need correct alternate-language annotations, want to audit what a CMS or plugin produced, or need hreflang for PDFs and other non-HTML files.
- Accepts
- Language/region codes with absolute URLs (form or bulk text) and an optional x-default — or pasted HTML <link> tags, an XML sitemap with xhtml:link elements, or HTTP Link headers
- Produces
- Identical, escaped hreflang sets as HTML tags, sitemap XML (one file per hosting origin) or a Link header value, and a validation report with errors, warnings and notes
Privacy
Everything runs in this browser page. What you type or paste isn't uploaded, saved in cookies or browser storage, or added to the page address. The tool never fetches, crawls or checks the URLs you enter, doesn't connect to Search Console, and parses pasted HTML and XML locally without running scripts or loading resources.
Limitations
- What hreflang is: an annotation that tells Google which URLs are language or regional versions of the same content, so it can show searchers the version in their language or for their region. It's a hint for choosing between alternates — it doesn't guarantee that a page is indexed or ranks well, and Google may still show another version.
- When you need it: when the same page exists in several languages (English, German, Arabic) or in versions for different regions of one language (en-GB, en-US, en-AU) with prices, spelling or shipping that differ. A site in a single language with no regional variants doesn't need hreflang.
- Hreflang versus the HTML lang attribute: <html lang> describes the language of the page you're on; hreflang links point to the other versions. Google doesn't use the lang attribute or the Content-Language header to find alternates — it uses hreflang and its own language detection — so set both, for different reasons.
- Language versus country codes: the value is an ISO 639-1 language code (en, de, ar), optionally followed by an ISO 3166-1 alpha-2 region (en-GB, de-AT) or an ISO 15924 script (zh-Hant, zh-Hans-US). A country code on its own isn't valid: Google doesn't derive the language from the country. The United Kingdom is GB, not UK (uk alone means Ukrainian); EU, UN and numeric regions such as es-419 (Latin America) aren't supported — list each country instead. Codes are case-insensitive; the tool writes them as en-US.
- Self-referencing and return links: every version must list itself and all its alternates, and every alternate must link back. If page A points to page B but B doesn't point back to A, Google may ignore those annotations. That's why the generator produces one identical set for every page in the cluster.
- What x-default means: x-default is a special value, not a language. It names the page for users whose language or region doesn't match any listed version — often a language selector or the international homepage. It's optional, a cluster has at most one, and it may share a URL with one of the language versions.
- HTML, XML sitemap or HTTP header: Google supports all three; use one method consistently. HTML <link rel="alternate" hreflang> elements go in the <head> of each page. A sitemap lists each URL in <loc> with xhtml:link children for every version, so the pages themselves stay unchanged. An HTTP Link header (Link: <https://…>; rel="alternate"; hreflang="en") works for non-HTML files such as PDFs and must be configured on your server — copying it here doesn't change any response.
- Cross-domain versions and sitemap hosting: alternate URLs may be on different domains (example.com, example.de). In a sitemap, though, each <loc> must follow normal sitemap hosting rules, so the generator writes one sitemap file per protocol and host: each file lists only its own site's pages in <loc>, while every entry still carries the complete cross-domain set. Host each file on its own site and submit it there.
- Hreflang and canonical URLs: list only canonical URLs in hreflang. Each language version should normally canonicalize to itself, not to one main language — a page that canonicalizes elsewhere is usually not the one shown, which makes its hreflang links useless. Hreflang doesn't replace canonical tags, and canonical tags don't replace hreflang.
- Typical mistakes: missing return links or self-references; country codes used as languages, en-UK instead of en-GB, or es-419; relative URLs (hreflang needs absolute URLs including https://); several URLs for one code; pointing hreflang at redirects, noindex or non-canonical pages; tags placed in the <body>; and different, incomplete sets on different versions.
- How to verify externally: after publishing, check that each version returns 200, is indexable and carries the same set — for example with a crawler, by inspecting the live HTML or response headers, and with the URL Inspection tool in Google Search Console. Those external steps can't be done here.
- Limits of local validation: the validator only checks the text you paste. It never fetches pages, so it can't tell whether a URL exists, redirects, is indexed, is canonical or returns a reciprocal annotation. With one page it checks syntax and the self-reference only; return links are verified only among pages you supply with their URLs, and links to pages you didn't supply are reported as unverified, never as confirmed errors.
- Code data and limits: language, region and script codes are checked against pinned ISO 639-1, ISO 3166-1 and ISO 15924 lists (Debian iso-codes 4.16.0), not just a pattern, and Google-unsupported forms such as three-letter languages, variants and extensions are rejected. This tool builds clusters of up to 200 versions and checks up to 5 MiB of pasted text or 50 pages at once; sitemap files must stay within the protocol's 50,000 URLs and 52,428,800 bytes, and this tool writes files up to 10 MiB.
- Escaping and safety: URLs are percent-encoded as UTF-8, internationalised hostnames become Punycode, and attribute values are escaped (a query string's & becomes &). Header values contain printable ASCII only, so no line break can be injected. Pasted HTML is read as text — scripts never run and nothing loads — and XML with a DOCTYPE or entity declaration is rejected unprocessed.
Tips
- Add your localized pages to an XML sitemap with the XML Sitemap Generator & Validator (/marketing/xml-sitemap-generator), make sure robots.txt doesn't block them with the Robots.txt Generator & Validator (/marketing/robots-txt-generator), and check each version's title and description with the Google SERP Snippet & Meta Tag Preview (/marketing/serp-snippet-preview).
How to create or check hreflang tags
- Enter each localized version of the same page: a language code such as en, de-AT or zh-Hant and the page's full https:// URL. Versions may be on different domains. Use Bulk text for larger clusters.
- Optionally add an x-default URL — the fallback page, often a language selector — and fix any row-specific errors.
- Choose HTML tags, XML sitemap or HTTP Link header, then copy or download the output. Put the same complete set on every version, including the page's own URL.
- Use Validate hreflang to check pasted tags, sitemaps or headers. Paste the annotations of each version with its URL to check return links between them.
Frequently asked questions
Does every language version need the same hreflang tags?
Yes. Each version should carry the same complete set: a link to itself and to every alternate, plus x-default if you use one. If page A links to page B but B doesn't link back, Google may ignore the annotations.
Is en-UK a valid hreflang code?
No. Region codes are ISO 3166-1 alpha-2, and the United Kingdom's code is GB, so use en-GB. On its own, uk is the language code for Ukrainian.
Can I use es-419 for Latin America?
Google's hreflang doesn't support numeric UN M.49 regions such as 419. List each country instead, for example es-MX, es-AR and es-CO, or use es for all Spanish speakers.
What is x-default and do I need it?
x-default names the fallback page for users whose language or region doesn't match any listed version — often a language selector. It's optional, there's at most one per cluster, and it may share a URL with one of the language versions.
Can hreflang alternates be on different domains?
Yes. Versions can live on different domains or subdomains. For sitemaps, the tool writes a separate file per host so each <loc> stays on its own site, while every file still lists all alternates.
Should I use HTML tags, a sitemap or HTTP headers?
Any of the three works for Google; choose one and use it consistently. HTML tags suit most pages, sitemaps avoid editing templates, and HTTP Link headers are for non-HTML files such as PDFs.
Does hreflang improve my rankings?
No. hreflang helps Google show the right language or regional version to the right users. It doesn't guarantee that pages are indexed or rank higher, and it doesn't replace canonical tags or good localized content.
Can the validator confirm that my return links work?
Only among the pages you paste with their URLs. The tool never fetches live pages, so links to pages you didn't supply are reported as unverified. Check the published pages with a crawler or Search Console.
Related marketing and SEO tools
Related guides
- 7 min readHow to Add Hreflang Tags for Two Language Versions of a PageMake English and Spanish pages point to each other with one identical hreflang set and an x-default, then check return links and catch US, en-UK, es-419 and relative URLs.
- 6 min readHow to Track Two Links to the Same Page in One Email NewsletterTag a newsletter's hero button and footer link with the same source, medium and campaign, tell them apart with utm_content, and check both links before you send.
- 8 min readHow to Make a WhatsApp Link with a Prefilled MessageBuild a wa.me link that opens a chat with your number and a ready-typed message, write the number so it works, encode the text, and fix the usual reasons links fail.

