A BCP-47 locale code is the standard language tag used throughout the web and software to identify a language and its regional or script variant. Tags follow the order language-script-region — for example en-US, fr-FR, or zh-Hans-CN. When building internationalized software you need a varied set of valid codes to test against. This tool generates random, well-formed BCP-47 codes, broken into their subtags, including right-to-left languages and script variants.
How it works
The generator keeps lists of real subtags: ISO 639 language codes, ISO 15924 script codes, and ISO 3166 region codes, with sensible pairings. When you generate:
- It picks a language at random, then a region that the language is commonly used in.
- For languages written in multiple scripts (such as Chinese or Serbian), it may add the appropriate script subtag, producing the three-part
language-script-regionform. - It assembles the subtags in correct BCP-47 order and flags whether the language is written right to left.
The result is a set of well-formed tags spanning two-part and three-part forms and both writing directions.
Tips and notes
- Always include at least one RTL locale (
ar,he,fa,ur) in your test matrix to catch layout-mirroring bugs. - Use the three-part script forms to verify your locale parser does not assume the simple
language-regionshape. - These codes are ideal for
hreflangattributes,Accept-Languageheaders, and i18n fixture data. - Everything runs locally in your browser, so the tool works offline and uploads nothing.