Hreflang Tag Generator

Generate hreflang link tags to serve the right language version of a page.

This tool runs entirely in your browser. Your files are never uploaded to a server.

What this tool does

Builds a set of link rel="alternate" hreflang="..." tags from a list of language/region codes paired with their matching URLs, telling search engines which URL to serve for each locale of the same page.

How to use it

For each row, enter a language code (and optionally a region, like en-US) and the full URL of that page's version in that language. Add more rows for additional languages, remove rows you don't need, and the generated tag block updates live below the list — copy it into the page's head.

Worked example

Adding en → https://example.com/en/page and tr → https://example.com/tr/page produces two lines: one hreflang="en" tag pointing to the English URL, and one hreflang="tr" tag pointing to the Turkish URL. Add a third entry with lang x-default pointing to a language-selector or default page to cover visitors whose language doesn't match any entry.

Language and region code format

Use an ISO 639-1 language code such as en or tr. Add an ISO 3166-1 region only when you have distinct content for that region, e.g. en-US versus en-GB — adding a region you don't actually have separate content for just adds tags without adding value.

Self-referencing tags and x-default

Each language version's page should list an hreflang tag pointing to itself, not just to the other versions — search engines expect the full set of alternates to appear identically on every page in the group. The special code x-default marks the fallback URL to show when a visitor's language doesn't match any of the listed alternates, commonly a language-selector page or your default locale.

Limitations

This tool only formats the tags you enter — it doesn't verify that the URLs exist, doesn't check that each target page also returns the same tags with itself included, and doesn't detect language/URL mismatches. Missing return tags on a target page are one of the most common reasons hreflang doesn't work as expected.

Scope, sources and privacy

Tag syntax follows Google Search Central's hreflang documentation, based on IETF BCP 47 language tags. Generation happens entirely in your browser; the codes and URLs you enter are never sent to a server.

Frequently Asked Questions

What format should the language code use?
Use ISO 639-1 language codes like 'en', optionally with an ISO 3166-1 region like 'en-US' or 'en-GB'.
Do I need a self-referencing tag?
Yes — each language version should include an hreflang tag pointing to itself as well as to every other version.
What is x-default for?
Add an entry with lang 'x-default' to specify the fallback page shown when no other hreflang matches the visitor.