Free tool
Hreflang Generator
Build hreflang tags for every language and region as HTML links, sitemap entries or an HTTP header.
How it works
What is the Hreflang Generator?
The Hreflang Generator is a free tool that writes hreflang annotations for pages that exist in more than one language or region. Add each URL with its language and optional region code, set an x-default, and copy the result as HTML link tags, XML sitemap entries or an HTTP Link header. It warns about malformed codes and a missing self-reference.
How to use the Hreflang Generator
- Add one row per version of the page: the full URL, the language code and, if needed, the region code.
- Enter an x-default URL for visitors who match none of the versions.
- Optionally enter the page you are tagging so the tool can check for a self-reference.
- Pick HTML, XML sitemap or HTTP header and copy the output.
What is hreflang?
hreflang is an annotation that tells search engines which language and, optionally, which country a version of a page is meant for. When the same content exists as en-US, en-GB and de, hreflang lets Google show each searcher the version written for them.
It is a signal about which URL to show, not a ranking boost. It also does not translate or redirect anything; it only describes versions that already exist at their own URLs.
How do I write a correct hreflang code?
The value is a language code in ISO 639-1 format, such as en, fr or de, optionally followed by a hyphen and a region code in ISO 3166-1 alpha-2 format, such as en-GB or fr-CA. A region on its own is not valid: GB alone means nothing, and the language always comes first.
The most common mistake is en-UK. The ISO code for the United Kingdom is GB, and the generator flags it. The tool checks the shape of each code, two letters each, and does not look the code up in the full ISO lists. It also does not handle script codes such as zh-Hant; write those by hand.
What are self-referencing and return tags?
Every page in a set must list all versions, including itself. That tag pointing at the page's own URL is the self-reference. Return tags are the other half: if the English page points to the German page, the German page must point back. Google says that when two pages do not point at each other, the tags may be ignored.
The generator handles this by producing one full set. Put the same block on every listed URL and both rules are met. In sitemap mode it writes a url entry for each version, each carrying the whole set.
Should I use HTML tags, the sitemap or the HTTP header?
Google accepts all three and treats them the same, so pick the one that is easiest to keep correct. HTML link tags in the head suit small sites. The sitemap method keeps the markup out of your pages and scales better; it needs the xmlns:xhtml namespace on the urlset element. The HTTP Link header is for files without HTML, such as PDFs.
Use one method per page set. If you maintain a sitemap already, build it with the XML Sitemap Generator and add the entries this tool writes.
What is x-default and do I need it?
x-default names the fallback URL for searchers whose language or region matches none of your listed versions. It is usually the global English page or a language selector. It is optional, but recommended once you have more than a couple of versions.
hreflang works alongside canonical tags, not instead of them. Each version should carry a canonical that points to itself, never to another language. Check that with the Canonical Tag Scanner.
Questions
- Does hreflang improve rankings?
- Not directly. It helps the right version appear for the right searcher, which can improve clicks and reduce bounces from people landing on the wrong language.
- Can two rows use the same URL?
- Yes. One URL can serve several codes, for example
en-USanden-CA. The reverse is not allowed: one code cannot point to two URLs, and the tool warns when that happens. - Do the URLs have to be absolute?
- Yes. Use the full URL including
https://. The generator warns about any row that is not a full URL. - Does hreflang work across different domains?
- Yes. The versions can live on separate domains, subdomains or folders, as long as every version lists all the others and itself.
- Is the Hreflang Generator free?
- Yes, with a free spyc.ai account. It runs in your browser, so nothing you type or paste is sent to a server.
Technical SEO Tools
More in Technical SEO Tools
Opengraph Viewer
Paste a URL and see the card it produces when someone shares it — title, description, image.
View OpengraphOpen Graph Generator
Write the Open Graph tags, preview the card, copy the markup.
Generate Open Graph tagsRobots.txt Checker
Fetch any site's robots.txt and test one URL against it: allowed, or blocked by which rule.
View robots.txtReady when you are
Before your next buyer asks AI about you, ask AI about yourself
One check, four engines, about twenty seconds. We show you the answers before we ask for anything.