Home › Developer Tools › Hreflang Tag Generator

Hreflang Tag Generator

List each language or regional version of a page, add an x-default fallback, and get validated hreflang code as HTML link tags, XML sitemap entries or HTTP Link headers. Everything runs in your browser.

Last updated:

Advertisement

How to use the Hreflang Tag Generator

  1. Enter each version of the page: its full URL, the language and, if it targets one country, the region.
  2. Add more rows with + Add language version, or press Paste a list to import lines such as de-at https://example.com/at/.
  3. Set x-default to the page for everyone else, such as your main site or a language picker.
  4. Fix any red messages in the checks panel (duplicates, relative URLs) and read the tips.
  5. Choose the output (HTML tags, XML sitemap or HTTP header) and press Copy code. Put the same set on every page in the group.

Example: one page in four versions

A store has English pages for the United States and the United Kingdom, a German page and a page for everyone else. Every one of the four pages carries the same block in its <head>:

<link rel="alternate" hreflang="en-US" href="https://shop.example/us/">
<link rel="alternate" hreflang="en-GB" href="https://shop.example/uk/">
<link rel="alternate" hreflang="de" href="https://shop.example/de/">
<link rel="alternate" hreflang="x-default" href="https://shop.example/">

A user searching in German from Austria gets the de page, a user in the UK gets en-GB, and a user in France, who matches nothing, gets the x-default page.

Common hreflang mistakes

MistakeCorrect
en-UKen-GB: ISO 3166-1 uses GB for the United Kingdom
US or eu on its ownA language is required (en-US); eu is the Basque language, not Europe
jp, cn, se, dkCountry codes used as languages. Japanese is ja, Chinese zh, Swedish sv, Danish da
en_USUse a hyphen: en-US
Relative URLs like /de/Absolute URLs including https:// and the host
No return linksEvery page lists every version, including itself
Hreflang pointing to redirected, noindex or non-canonical URLsPoint only to the final, indexable, canonical URL of each version

Choosing between language and language-region codes

Use a plain language code (es) when one version serves all speakers of that language. Add regions only when the content really differs, for example prices in another currency, different shipping, or spelling such as color and colour. If you create regional variants such as es-ES and es-MX, also consider a general es page (or mark one of them as es as well) so Spanish speakers in other countries still get a Spanish page. Make sure each version also has a self-referencing canonical tag; the meta tag generator can help with the rest of the head, and the sitemap generator builds the base sitemap.

Frequently asked questions

What is hreflang?

Hreflang is an attribute that tells search engines which language and, optionally, which country a page is written for, and where its equivalents in other languages are. Google uses it to show the right version in search results, for example the en-GB page to users in the United Kingdom and the de page to German speakers.

What format does an hreflang value use?

A language code from ISO 639-1 (two letters, such as en, de or ja), optionally followed by a hyphen and a region from ISO 3166-1 alpha-2 (such as GB, US or AT): en-GB, de-AT, es-MX. A region can never be used alone. The value is case-insensitive. A common mistake is en-UK: the correct code for the United Kingdom is GB.

What is x-default?

x-default is a special value for the page to show when no other version matches the user's language or location. It usually points to your main or international page, or to a language selection page. It is optional but recommended.

Does each page need to reference itself?

Yes. Every page in the set should list all versions, including itself, and every version must link back to the others. If page A points to page B but B does not point back to A, search engines may ignore the annotation. The easiest way is to put the identical block of tags on every page.

Should I use HTML tags, the sitemap or HTTP headers?

They are equivalent; use one method per page. HTML link tags in the <head> are the simplest for small sites. XML sitemaps keep the markup out of your pages and suit large sites. HTTP Link headers are the only option for non-HTML files such as PDFs.

Is hreflang the same as a canonical tag?

No. A canonical tag picks the preferred URL among duplicates, while hreflang links equivalent pages in different languages. Each language version should have a self-referencing canonical, not a canonical pointing to another language.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Sitemap GeneratorTurn a list of URLs into a valid XML sitemap file.Meta Tag GeneratorCreate SEO, Open Graph and X meta tags with live previews.Robots.txt GeneratorBuild a robots.txt file with rules, sitemap lines and AI-bot blocking presets.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Privacy Policy GeneratorCreate a privacy policy for your website or app with CCPA, CalOPPA, COPPA and AdSense sections.UTM Campaign URL BuilderAdd UTM tracking parameters to links and make a QR code.SERP Snippet PreviewPreview your title tag and meta description with pixel-accurate truncation on desktop and mobile.Canonical Tag GeneratorNormalize URLs and create rel=canonical tags and HTTP headers, for one page or a whole list.Content Security Policy GeneratorBuild a CSP header or meta tag with nonces, hashes, presets and report-only mode.Meta Tag AnalyzerPaste page HTML to audit title, description, canonical, robots, Open Graph and hreflang tags.Robots.txt TesterTest whether a URL is allowed or blocked by robots.txt for Googlebot and other crawlers.Sitemap URL ExtractorExtract every URL from a sitemap.xml or sitemap index, validate it and export to CSV or TXT.Cookie Consent Banner GeneratorDesign a cookie banner with accept, reject and settings buttons and copy the HTML/CSS/JS.FAQ Schema GeneratorTurn questions and answers into FAQPage JSON-LD markup with validation and a preview.Google Review Link GeneratorTurn a Google Place ID into a direct review link, QR code and printable review card.Keyword Suggestion ToolTurn one seed keyword into hundreds of Google and YouTube autocomplete keyword ideas.Local Business Schema GeneratorCreate LocalBusiness JSON-LD with address, geo, opening hours, holiday hours and sameAs links.Structured Data ValidatorCheck JSON-LD, microdata and RDFa against schema.org and Google rich result requirements.Terms and Conditions GeneratorCreate terms of service for a website, store, SaaS or app, with payments and governing law.Breadcrumb Schema GeneratorBuild BreadcrumbList JSON-LD plus the matching HTML breadcrumb from names and URLs.Cookie Policy GeneratorCreate a cookie policy with a ready cookie table for Google Analytics, AdSense, Meta Pixel and more.Disclaimer GeneratorWrite a website disclaimer for affiliate, health, finance or blog sites, with short post notices.Keyword CombinerCombine up to 4 keyword lists into every combination in broad, phrase and exact match.Long Tail Keyword GeneratorTurn a seed keyword into long-tail keywords with best, how to, near me, year and for X modifiers.On-Page SEO CheckerPaste page HTML and a keyword to audit title, meta, headings, alt text and keyword use.App Privacy Policy GeneratorCreate a privacy policy for your iOS or Android app from its SDKs, permissions and data.URL Tracking RemoverStrip utm, fbclid, gclid and other tracking parameters from one link or hundreds at once.YouTube Keyword ToolFind YouTube search suggestions for a video topic with A-Z expansion and copy them as tags.
See all 28 SEO & Marketing Tools →