Zahid Awais Get a free audit

Free hreflang tag generator

Turn your language and region URLs into valid hreflang tags, sitemap entries or HTTP headers.

By Zahid Awais · Technical SEO tools · Free, private, no sign-up

Codes: language (ISO 639-1) plus optional region (ISO 3166-1), for example en, en-gb, pt-br, zh-hant.

Result
0Versions
0Tags per page
0Issues

    The free hreflang tag generator runs in your browser, needs no sign-up and never sends what you type anywhere.

    Quick answer

    This hreflang tag generator turns a list of language codes and URLs into hreflang link tags, XML sitemap entries or HTTP Link headers. The key rule: every version must list itself and every other version, use an ISO 639-1 language code with an optional ISO 3166-1 region (en-gb, not en-uk), and add x-default for a fallback page.

    What is a hreflang tag generator?

    A hreflang tag generator is a tool that writes rel="alternate" hreflang annotations so search engines can show the right language or regional URL to each searcher. It takes each code and URL pair and outputs the full set of alternates, including a self reference and an optional x-default, for every page in the group.

    How do you use the Hreflang Tag Generator?

    How to use the Hreflang Tag Generator: enter details, see the result and copy it
    Real screenshot of the Hreflang Tag Generator with the steps marked.
    1. Enter one version per line as a code and a full URL separated by a comma, for example en-gb, https://example.com/uk/.
    2. Add an x-default URL for the page users should see when no language matches, such as a language selector or your main version.
    3. Pick the output format: HTML link tags for the head, XML sitemap entries, or HTTP Link headers for PDFs and other files.
    4. Read the checks below the code and fix any invalid codes, duplicate codes or relative URLs.
    5. Copy or download the code and add the same full set of tags to every URL in the group.

    Do hreflang tags need return links?

    Yes, every page in a hreflang group must link back to every other page, or Google may ignore the annotations. If the US page lists the UK page but the UK page does not list the US page, that pair is not trusted. The simplest fix is to put the identical block of tags, including the self reference, on every version. Google explains this in its localized versions guide.

    Is it en-uk or en-gb for hreflang?

    Use en-gb, because the ISO 3166-1 code for the United Kingdom is GB, not UK. A tag like en-uk is invalid and gets ignored. The language part comes first (ISO 639-1) and the optional region second (ISO 3166-1 Alpha 2), and a region code can never be used on its own.

    What does x-default mean in hreflang?

    x-default marks the fallback URL for users whose language or region does not match any version you listed. It is ideal for a language selector page or an automatically redirecting home page, but it can also point to your main language version. You only need one x-default per group of alternates.

    Quick reference

    CodeMeansValid?
    enEnglish speakers anywhereYes
    en-gbEnglish speakers in the United KingdomYes
    en-ukIntended UK, but UK is not an ISO region codeNo, use en-gb
    es-419Spanish for Latin AmericaNo, Google does not support it
    de-chGerman speakers in SwitzerlandYes
    x-defaultFallback when no other code matchesYes

    Worked example

    Example

    Example: a shop has https://example.com/ for the US, https://example.com/uk/ for the UK and https://example.com/de/ for Germany. Entering en-us, en-gb and de-de with those URLs and x-default set to https://example.com/ produces 4 link tags. The same 4 lines go on all 3 pages, so 12 tags in total.

    Frequently asked questions

    Where do I put hreflang link tags?

    Put the link tags inside the head section of each page, before the closing head tag. Every version of the page gets the same full list, including a tag pointing to itself. If you cannot edit the head, use the XML sitemap method or HTTP headers instead.

    Should I use HTML tags or a sitemap for hreflang?

    Both work equally for Google, so pick the one that is easiest to keep accurate. HTML tags suit small sites, while sitemap entries suit large sites because they do not add weight to each page. Avoid using several methods with conflicting data, since mismatches make debugging hard.

    Do hreflang URLs need to be absolute?

    Yes. Each hreflang URL should be a full address with protocol and domain, such as https://example.com/de/. Relative paths are a common source of errors. The URLs should also be the canonical, indexable versions that return a 200 status, not redirects or noindexed pages.

    Can I target a country without a language?

    No. The language code is required and the region is optional. You can use de for all German speakers or de-at for German speakers in Austria, but you cannot use at alone. To target one country with several languages, add one entry per language, such as de-ch and fr-ch.

    Does hreflang help rankings?

    Hreflang does not boost rankings directly. It helps Google swap in the right language or regional URL for each searcher, which can lower bounce rates and stop your own versions from competing for the same query. Content still needs to be properly translated or localized.

    Is this hreflang generator free and private?

    Yes. The tool runs entirely in your browser, so the URLs you enter are not sent to any server or stored. You can use it as often as you like, and the checks are simple format checks, so always verify the live result in Search Console.

    Sources

    Facts checked against these official pages. Read how I check facts in my editorial policy.

    Related free tools

    All 104 tools

    XML Sitemap Generator from URL List

    A sitemap generator from a URL list is a tool that wraps each URL in the loc element of the sitemaps.org XML…

    Coming 9 Oct

    Canonical Tag Generator

    A canonical tag generator is a tool that builds the link rel="canonical" element telling search engines which…

    Coming 10 Oct

    Redirect Map Generator

    A redirect map generator is a tool that builds the old URL to new URL table you need before a site migration.…

    Coming 10 Oct

    Want a full audit instead?

    Send your website and I will check it for you, free.

    Get my free audit
    Chat on WhatsApp