Hreflang tag generator

Write one line per language version: the code, a space, then the full URL. The tool checks the codes, normalises their spelling, adds an x-default entry if you like and prints the tags in the format you need.

Format
x-default

4 alternates written.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Write one line per language version, such as en https://example.com/. A space, tab, comma or = can separate the code from the URL.
  2. Choose the output: link tags for the page head, an HTTP header, or sitemap XML.
  3. Decide on x-default. Copy the result into every language version (for tags and headers) or into the sitemap.

How it works

Each code is checked against the pattern language[-script][-region] and written as language in lowercase, script with a capital first letter and region in capitals. URLs are checked for an http or https address, and & is escaped in markup. Duplicate codes are rejected, because a language-region pair can point to only one page.

Example

The lines en https://example.com/ and de-de https://example.com/de/ with the first-URL option give three tags: en, de-DE and x-default, the last one pointing to https://example.com/.

Tips

  • The set must be reciprocal: if the English page lists the German one, the German one must list the English one.
  • Use the same URLs as your canonical tags.

Frequently asked questions

Where do hreflang tags go?

Use one of three places: link tags in the head of every language version, an HTTP Link header (useful for files such as PDFs), or the XML sitemap. Pick one method for a site. Whichever you choose, every version must list all versions, itself included.

What are valid hreflang codes?

A two- or three-letter language code, optionally followed by a four-letter script and a two-letter region or three-digit region, such as en, en-GB, pt-BR, zh-Hant-TW or es-419. The special value x-default marks the page for visitors whose language is not listed. The tool writes the language in lowercase and the region in capitals, which is the usual spelling.

What is x-default for?

It names the fallback page, for example a language chooser or your main version. It is optional. The first-URL option uses your first line as the fallback; write a line starting with x-default if you want a different one.

Do the URLs need to be complete?

Yes. Use absolute addresses with http:// or https://, and the same form (with or without a trailing slash, www or not) that the page actually serves.

Why does the sitemap output repeat the links?

In a sitemap each url entry lists all of its alternates, including itself, so the full set appears once per address. The tool writes that out and adds the xhtml namespace the format needs.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.