FormatterHQ

Hreflang Tag Generator

List your language versions and get correct hreflang annotations — HTML link tags, sitemap entries or an HTTP Link header — including x-default and code validation.

Input TEXT
Output HTML
Ready.

How to use the Hreflang Tag Generator

  1. Enter one language version per line: an hreflang code and the absolute URL, e.g. en-GB https://example.com/uk/.
  2. Optionally set an x-default URL for users whose language you do not target.
  3. Choose the Output: HTML <link> tags, XML sitemap entries or HTTP Link header.
  4. Copy the result and add it to every page in the set.

Generate hreflang tags for multilingual sites

When the same content exists in several languages or for several countries, hreflang annotations tell Google and Yandex which version to show to which users. Without them, a German visitor may land on your US page, or regional versions may compete with each other. This hreflang generator checks the format of your language codes and outputs the annotations in three formats.

Example

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

Rules that matter

  • Codes: an ISO 639-1 language (de), optionally followed by an ISO 3166-1 region (de-AT). A region alone, such as uk, is invalid — and "uk" is actually Ukrainian. The generator rejects malformed codes and normalises case (en-gb → en-GB, zh-hans-cn → zh-Hans-CN). It checks the shape of a code, not a list of real codes, so a three-letter language such as eng, a numeric region such as es-419 and a wrong region such as en-UK are accepted as typed. The same code entered twice, in any letter case, is reported as a duplicate.
  • Return links: every page in the set must list all versions, including itself. If page A points to B but B does not point back, search engines ignore the pair.
  • Absolute URLs are required, and they should be the canonical URLs of each version.
  • x-default marks the fallback page, often a language selector or your main international version.

Choosing the hreflang generator output

HTML tags go in the <head> of each page and are the most common choice. XML sitemap entries keep annotations out of your templates, which is convenient for large sites — generate the base sitemap with the XML sitemap generator and add the xhtml namespace. The HTTP Link header is the only option for non-HTML files such as PDFs.

The sitemap and header formats side by side

In a sitemap, each <url> repeats the full set of alternates, and the <urlset> element must declare xmlns:xhtml="http://www.w3.org/1999/xhtml":

<url>
  <loc>https://www.example.com/en/</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/"/>
  <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/"/>
</url>

For a PDF, the server sends the same information in one header, with the alternates separated by commas:

Link: <https://www.example.com/en/guide.pdf>; rel="alternate"; hreflang="en",
      <https://www.example.com/de/guide.pdf>; rel="alternate"; hreflang="de"

Pick one method per page set; mixing them makes errors harder to trace.

Common mistakes

Pointing hreflang at redirected or noindexed URLs, using a canonical tag that points all language versions to one page, and forgetting self-references are the errors seen most often in audits. Check your other head tags with the meta tag generator.

Language or language plus region?

Use a bare language code when a page serves all speakers of that language, such as de for one German site. Add a region only when content really differs between countries — prices in euros versus Swiss francs, different shipping, spelling differences between en-US and en-GB. You can combine both: en as a general English page plus en-GB and en-AU for specific markets. Users whose region is not listed then get the general language version.

Privacy

The tool runs entirely in your browser. Nothing you type or paste is sent to our servers.

Frequently asked questions

Do I need hreflang if my site is only in one language?
No. Hreflang is only needed when you have equivalent pages in several languages or for several regions.
What is x-default?
It specifies the page to show when no other language or region matches the user, typically a language picker or your main international page.
Is it en-UK or en-GB?
en-GB. Region codes follow ISO 3166-1, where the United Kingdom is GB. The generator checks only the shape of a code, so it accepts en-UK without a warning; correct it yourself.
Does Google use hreflang for ranking?
Hreflang does not boost rankings; it helps Google show the right language or regional version of a page to each user.
Does Bing support hreflang?
Bing primarily uses the content-language meta tag and other signals, so consider adding that as well for Bing.

Last updated October 3, 2026

Related tools

Barcode Generator Generate Code 128, EAN-13, UPC-A, Code 39, ITF-14, ISBN, Data Matrix, PDF417 and more barcodes. Download PNG or SVG for free. Basic Auth Header Generator Build an HTTP "Authorization: Basic" header from username:password, or decode an existing Basic auth header back to credentials. Bcrypt Hash Generator Generate a bcrypt password hash ($2y$) with a configurable cost factor, compatible with PHP password_hash and Laravel. Crontab Generator Build a crontab line from presets or custom fields, with a plain-English explanation and a preview of the next run times. CSR Generator Generate an RSA private key and certificate signing request (CSR) with SANs in your browser — the private key never leaves your device. ECDSA & Ed25519 Key Generator Generate elliptic-curve key pairs (P-256, P-384, P-521) and Ed25519 keys as PEM or JWK for JWT signing, TLS and APIs. .htaccess Redirect Generator Generate Apache .htaccess 301/302 redirects from old → new URL pairs, plus force-HTTPS, www and trailing-slash rules. Meta Tag Generator Generate SEO meta tags for your page head: title, description, keywords, robots, canonical, Open Graph and Twitter cards. Open Graph & Twitter Card Preview Paste your page’s meta tags and preview the link on Facebook, X/Twitter, LinkedIn, Slack and Discord, with fixes for missing tags. Robots.txt Generator Create a robots.txt file: allow or block paths, block AI crawlers and specific bots, set crawl-delay and add your sitemap URL. SERP Snippet Preview & Meta Length Checker Check title tag and meta description length in pixels and characters and preview your Google search result on desktop and mobile. UTM Campaign URL Builder Build Google Analytics campaign URLs with utm_source, utm_medium, utm_campaign, utm_term and utm_content, consistently formatted.