Hreflang Tag Generator
Build correct hreflang annotations for international SEO — define your locale↔URL map once and get a complete, bidirectional set (self-referencing + x-default) that's valid by construction. Full ISO language/region database, a linter for the mistakes Google flags (en-UK, underscores, missing return tags), and four output formats: HTML, XML sitemap, HTTP header, and Next.js metadata.
About this ToolHow it works, benefits & use casesTap to collapse
Hreflang annotations tell Google which language and regional version of a page to serve to which users — and getting the codes, the x-default, and the bidirectional structure right is what separates a working international setup from a broken one. This generator builds those annotations from a list of language/region/URL entries. Pick a language from a built-in list (English, Spanish, French, German, Chinese, Japanese, Arabic, and more) and an optional region (US, GB, DE, JP, …); the tool formats each into a proper code like en or en-US (lowercase language, uppercase region). Choose your output: HTML <link rel="alternate"> tags for the page head, or an XML sitemap using the xhtml:link namespace. You can include an x-default entry for users whose language you do not target. On generation it runs validation and warns about duplicate hreflang codes, a missing x-default, invalid URLs, and mixed HTTP/HTTPS protocols. It all runs in your browser.
How to Use
- 1Choose your "Output format": HTML <link> tags or XML Sitemap.
- 2Decide on x-default — leave "Include x-default" checked and enter the x-default URL, or uncheck it.
- 3Add language entries: for each, pick a Language (required), an optional Region, and enter the URL. Use "Add entry" for more and the trash icon to remove.
- 4Click "Generate Hreflang Tags".
- 5Review any warnings shown, then copy or download the output (hreflang-tags.html or hreflang-sitemap.xml).
Key Benefits
- Two output formats from the same entries: HTML <link> tags or an XML sitemap with the xhtml namespace
- Built-in language and region pickers that format codes correctly (lowercase lang, uppercase region)
- Optional x-default entry for untargeted languages, placed first in the output
- Validation warnings for duplicate codes, missing x-default, invalid URLs, and mixed protocols
- XML output groups multiple language alternates under each unique URL automatically
- Best-practices guidance shown alongside the generator
- Runs entirely in the browser — nothing is uploaded
Common Use Cases
- Annotating a page that exists in several languages so each ranks for the right audience
- Targeting regional variants like en-US and en-GB that share a language
- Producing an XML sitemap with hreflang alternates to submit to Search Console
- Adding an x-default fallback for international visitors you do not specifically target
- Catching duplicate or mismatched hreflang codes before they cause indexing problems
Put this identical block on every listed page
<link rel="alternate" hreflang="en-US" href="https://example.com/" /> <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" /> <link rel="alternate" hreflang="es-ES" href="https://example.com/es/" /> <link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" />
Valid hreflang set (4 locales)
Locales (4)
ISO code reference (154 languages · 188 regions)
abAbkhazianaaAfarafAfrikaansakAkansqAlbanianamAmharicarArabicanAragonesehyArmenianasAssameseayAymaraazAzerbaijanibmBambaraeuBasquebeBelarusianbnBengalibhBiharibsBosnianbrBretonbgBulgarianmyBurmesecaCatalanchChamorroceChechenzhChinesecvChuvashkwCornishcoCorsicanhrCroatiancsCzechdaDanishnlDutchdzDzongkhaenEnglisheoEsperantoetEstonianeeEwefoFaroesefjFijianfiFinnishfrFrenchfyFrisianglGaliciankaGeorgiandeGermanelGreekgnGuaraniguGujaratihtHaitian CreolehaHausaheHebrewhiHindihoHiri MotuhuHungarianisIcelandicigIgboidIndonesianiaInterlinguaieInterlingueiuInuktitutikInupiaqgaIrishitItalianjaJapanesejvJavaneseklKalaallisutknKannadakrKanuriksKashmirikkKazakhkmKhmerkiKikuyurwKinyarwandakyKyrgyzkvKomikgKongokoKoreankuKurdishloLaolaLatinlvLatvianlnLingalaltLithuanianlbLuxembourgishmkMacedonianmgMalagasymsMalaymlMalayalammtMaltesemiMaorimrMarathimnMongoliannaNaurunvNavajoneNepalinoNorwegiannbNorwegian BokmålnnNorwegian NynorsknyNyanjaocOccitanorOriyaomOromopsPashtofaPersianplPolishptPortuguesepaPunjabiquQuechuarmRomanshroRomanianruRussiansmSamoansgSangosaSanskritgdScottish GaelicsrSerbiansnShonasdSindhisiSinhalaskSlovakslSloveniansoSomalistSouthern SothoesSpanishsuSundaneseswSwahilissSwatisvSwedishtlTagalogtgTajiktaTamilttTatarteTeluguthThaiboTibetantiTigrinyatoTongantsTsongatnTswanatrTurkishtkTurkmentwTwiugUyghurukUkrainianurUrduuzUzbekveVendaviVietnamesecyWelshwoWolofxhXhosayiYiddishyoYorubazuZuluADAndorraAEUnited Arab EmiratesAFAfghanistanAGAntigua and BarbudaALAlbaniaAMArmeniaAOAngolaARArgentinaATAustriaAUAustraliaAZAzerbaijanBABosnia and HerzegovinaBBBarbadosBDBangladeshBEBelgiumBFBurkina FasoBGBulgariaBHBahrainBJBeninBNBruneiBOBoliviaBRBrazilBSBahamasBTBhutanBWBotswanaBYBelarusBZBelizeCACanadaCDDR CongoCFCentral African RepublicCGCongoCHSwitzerlandCICôte d'IvoireCLChileCMCameroonCNChinaCOColombiaCRCosta RicaCUCubaCVCape VerdeCYCyprusCZCzechiaDEGermanyDJDjiboutiDKDenmarkDMDominicaDODominican RepublicDZAlgeriaECEcuadorEEEstoniaEGEgyptEREritreaESSpainETEthiopiaFIFinlandFJFijiFMMicronesiaFRFranceGAGabonGBUnited KingdomGDGrenadaGEGeorgiaGHGhanaGMGambiaGNGuineaGQEquatorial GuineaGRGreeceGTGuatemalaGWGuinea-BissauGYGuyanaHKHong KongHNHondurasHRCroatiaHTHaitiHUHungaryIDIndonesiaIEIrelandILIsraelINIndiaIQIraqIRIranISIcelandITItalyJMJamaicaJOJordanJPJapanKEKenyaKGKyrgyzstanKHCambodiaKPNorth KoreaKRSouth KoreaKWKuwaitKZKazakhstanLALaosLBLebanonLCSaint LuciaLILiechtensteinLKSri LankaLRLiberiaLSLesothoLTLithuaniaLULuxembourgLVLatviaLYLibyaMAMoroccoMCMonacoMDMoldovaMEMontenegroMGMadagascarMKNorth MacedoniaMLMaliMMMyanmarMNMongoliaMOMacaoMRMauritaniaMTMaltaMUMauritiusMVMaldivesMWMalawiMXMexicoMYMalaysiaMZMozambiqueNANamibiaNENigerNGNigeriaNINicaraguaNLNetherlandsNONorwayNPNepalNZNew ZealandOMOmanPAPanamaPEPeruPGPapua New GuineaPHPhilippinesPKPakistanPLPolandPRPuerto RicoPSPalestinePTPortugalPYParaguayQAQatarRORomaniaRSSerbiaRURussiaRWRwandaSASaudi ArabiaSCSeychellesSDSudanSESwedenSGSingaporeSISloveniaSKSlovakiaSLSierra LeoneSNSenegalSOSomaliaSRSurinameSSSouth SudanSVEl SalvadorSYSyriaSZEswatiniTDChadTGTogoTHThailandTJTajikistanTLTimor-LesteTMTurkmenistanTNTunisiaTOTongaTRTurkeyTTTrinidad and TobagoTWTaiwanTZTanzaniaUAUkraineUGUgandaUSUnited StatesUYUruguayUZUzbekistanVAVatican CityVCSaint VincentVEVenezuelaVNVietnamVUVanuatuWSSamoaYEYemenZASouth AfricaZMZambiaZWZimbabweGet return tags right the first time
Hreflang’s most common failure — and the error Google Search Console reports most — is missing return tags: page A points to B, but B never points back. This tool removes that whole class of bug. You describe each language/region version once with its URL, and we emit the complete, symmetric annotation set — every locale, self-referencing, plus x-default. Put that identical block on every listed page and reciprocity is guaranteed by construction.
What the linter catches
en-UKinstead ofen-GB— “UK” isn’t an ISO region code.- Underscores (
en_US) instead of hyphens, and wrong casing. - Region-only codes — hreflang must always start with a language.
- Duplicate locales, mixed http/https, and missing
x-default.
Which format should I use?
Use HTML <link> tags for normal pages, an XML sitemapwhen you’d rather centralize annotations (great for large sites), an HTTP Link headerfor non-HTML files like PDFs, or the Next.js metadata.alternates block in the App Router. All four describe the same set.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- HTML FormatterFormat and beautify HTML code
- Text to SlugConvert text to URL-friendly slugs
- Meta Tags GeneratorGenerate meta tags for SEO and social media
- Sitemap Priority CalculatorPaste a list of URLs and get a complete XML sitemap with priorities from a transparent, tunable model — each URL auto-classified by type & depth, with a per-row score breakdown and priority distribution analysis
- Markdown Link CheckerCheck for broken links in Markdown files
- UTM Parameter GeneratorBuild consistent UTM campaign URLs with smart slugification, decode existing URLs, and generate a full sources × mediums × creatives matrix at once — export to CSV/TSV/JSON for your campaign spreadsheet
HTML mode produces <link rel="alternate" hreflang="…" href="…"> tags meant to go in each page's <head>. XML mode produces a sitemap using the xhtml:link namespace, where all language alternates for a URL are grouped under a single <url> entry — this is submitted to your search console instead of being placed on the page.
x-default specifies the fallback page for users whose language or region you do not explicitly target — typically a language selector or your primary international landing page. The tool recommends it for international sites and warns when it is omitted. When included, it is listed first in both the HTML and XML output.

