SEO Tools
Hreflang Tag Generator
Turn language codes and URLs into hreflang link tags, an HTTP Link header or sitemap entries. Codes are validated and fixed, such as en-UK to en-GB.
How to use Hreflang Tag Generator
Enter a language code and URL on each line, such as en-GB, https://example.com/uk/, plus an optional x-default URL. Choose HTML tags, an HTTP Link header or an XML sitemap. Errors and fixes are shown as you type.
- List each language versionWrite one code and URL per line, separated by a comma, space, tab or |. Relative paths work if you set the site address.
- Add an x-default pageEnter the fallback URL for users whose language matches none of yours, such as a language picker.
- Copy the chosen formatCopy the link tags into every version's head, or use the Link header for non-HTML files or the sitemap XML.
How hreflang codes are checked
An hreflang value is an ISO 639-1 language code, optionally followed by an ISO 3166-1 region: en, en-GB, fr-CA. The generator fixes case and underscores (en_gb becomes en-GB), converts aliases such as en-UK to en-GB and rejects country codes typed as languages – jp should be ja, and gb or us on their own are not languages. It also rejects numeric regions such as 419, extra subtags and unknown codes, and flags three-letter codes where a two-letter one may exist. Each code is listed with its name, e.g. en-GB = British English, so mistakes stand out.
Return links, x-default and choosing a format
Hreflang only works when every version lists all the others, including itself. If the English page points to the French page but not back, search engines may ignore the pair, so copy the same block to every version's head. Alternatively, choose the sitemap format, where each url entry lists all versions and no head tags are needed. x-default names the page for users whose language matches none of yours; without it, the tool warns when you have regional codes such as en-GB but no plain en version. Several codes may share one URL when a page serves more than one region.
Accuracy and data handling
Generated tags and rules must match the real page content and the site's deployment environment. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
Is it en-UK or en-GB?
en-GB. GB is the ISO code for the United Kingdom, and the generator corrects en-UK to en-GB automatically. On its own, uk is the code for Ukrainian, so the tool warns if you use it.
Do I need x-default?
It is optional but recommended. It tells search engines which page to show users whose language or region matches none of your versions, such as a language selection page or your main site.
Should hreflang URLs be canonical?
Yes. Each URL should be the canonical, indexable version of the page. The generator strips # fragments and warns about tracking parameters such as utm_source in the URLs.
Can I put hreflang in a sitemap instead?
Yes. Choose XML sitemap output: every page gets a url entry listing all language versions as xhtml:link alternates, so you don't need the tags in each page's head.
More SEO Tools
Related toolsNormalise URLs and generate rel=canonical link tags or HTTP Link headers
Build schema.org JSON-LD for nine common types with required-field checks
Convert Q&A text into FAQPage JSON-LD and matching on-page FAQ HTML
Build BreadcrumbList JSON-LD or breadcrumb HTML from a list or a single URL
Bulk-convert old and new URL pairs into Nginx, Apache, Cloudflare and Netlify redirects
Pull hostnames and root domains from URL lists, with counts and de-duplication