BYTETOOLS

Hreflang XML Sitemap Generator

Turn language and URL pairs into a valid hreflang XML sitemap with reciprocal alternate links, validated ISO language and region codes and one x-default per group.

hreflang sitemap.xml

Putting hreflang in the sitemap keeps the return links in one file instead of repeating them in every page head — Google treats both signals the same way. Language codes are validated against ISO 639-1 and ISO 3166-1 locally; nothing is uploaded.

What is the Hreflang XML Sitemap Generator?

Declaring hreflang in your sitemap keeps the return links in one file instead of repeating the whole alternate set inside every page's head.

  • Complete reciprocal alternate set in every url entry, self-reference included
  • ISO 639-1 language and ISO 3166-1 region validation with plain-English errors
  • Catches en-UK, de-EU, duplicate codes and multiple x-default entries
  • Canonical casing applied: lowercase language, Titlecase script, uppercase region
  • Optional lastmod on every entry and the xhtml namespace declared correctly
  • Copy or download the sitemap — every check runs locally

How to use the Hreflang XML Sitemap Generator

  1. 1

    Paste one language code and URL pair per line — either column order is accepted.

  2. 2

    Separate each set of translations of the same page with a blank line.

  3. 3

    Add an x-default line to each group for the fallback URL, if you use one.

  4. 4

    Fix any invalid language or region codes reported below the box.

  5. 5

    Optionally add a lastmod date, then copy the XML or download the sitemap.

About the Hreflang XML Sitemap Generator

Declaring hreflang in your sitemap keeps the return links in one file instead of repeating the whole alternate set inside every page's head. Google treats the two signals identically, and the sitemap version is far easier to regenerate when you add a language. Paste your language and URL pairs, separate each group of translations with a blank line, and the XML is built as you type.

Every url entry receives the complete reciprocal alternate set, including a self-reference — the requirement that most hand-written hreflang implementations get wrong. Language codes are validated against ISO 639-1 and regions against ISO 3166-1, so classic mistakes like en-UK or de-EU are caught, and each group may declare only one x-default.

The file is assembled entirely in your browser. No URL is fetched, nothing is crawled and none of your language mapping is uploaded.

Frequently asked questions

Is hreflang in a sitemap better than in the head?

Google treats them the same, so it is a maintenance choice. The sitemap keeps every return link in one editable file, which is much easier when you have dozens of locales; head tags keep the mapping next to the page but must be repeated on every URL.

Does every hreflang entry need a self-reference?

Yes. Each page must list itself in its own alternate set alongside the other languages. This generator adds the self-reference automatically for every URL in a group, so you cannot forget it.

Why is en-UK invalid in hreflang?

The region subtag uses ISO 3166-1 alpha-2 codes, and the United Kingdom's code is GB, not UK. Writing en-UK makes Google ignore the annotation entirely, so this tool flags it and tells you to use en-GB instead.

How many x-default entries can a group have?

Exactly one. x-default names the fallback page for visitors whose language does not match any of your versions, so a second one makes the set ambiguous. The tool reports an error if a group declares more than one.

Do hreflang URLs have to be absolute?

Yes. Relative URLs are ignored, so every href must be a complete http or https address including the hostname. Any non-absolute entry is rejected here with a message naming the offending line.

Related tools