Locale Code Validator
Check whether text is a valid locale code as you type it, right in your browser, without sending it anywhere.
Input
Output
No value
Guide
What is a locale code?
A locale code names a language, often with the region where it's used, so software can pick the right translation and show dates, numbers and prices the local way. The usual form is a BCP 47 language tag: a language code, then optionally a script and a region, joined by hyphens. en-US is English as used in the United States, fr-CA French in Canada, es-419 Spanish in Latin America, and sr-Latn-RS Serbian in Latin letters as used in Serbia. The IETF sets the rules for these tags, and IANA keeps the registry of the languages, scripts and regions they can use.
You meet locale codes in browser and phone language settings, the lang and hreflang attributes of web pages and app translation files. Developers, translators and website owners check them when they add a language to an app or site or set up hreflang tags.
Tool description
Type or paste a code into the Locale code field, and the result shows as you type: "Locale code is valid" or "Locale code is not valid". Spaces and line breaks around the code are ignored. The page has no settings.
What passes and what fails
The page checks the shape of the tag, part by part, not whether each part is in the registry.
- A language of two or three letters, alone or with more parts:
fr,gswfor Swiss German,de-CH - A script of four letters and a region of two letters or three digits:
zh-Hans-CN,es-419 - Variants and extensions at the end:
de-DE-1901for German with the spelling rules of 1901,th-TH-u-nu-thaifor Thai with Thai digits - Hyphens or underscores between the parts, in any case:
en-US,en_USanden-usall pass - Names with an encoding or a modifier, as Linux writes them, fail:
en_US.UTF-8,de_DE@euro - Spaces, dots and empty parts fail:
en US,en.US,en-
Good to know
- Since only the shape is checked, made-up codes pass:
zz-ZZdoes, and so does any word of five to eight letters, such ashello, because registered language subtags can be that long. A four-letter word such astestfails. en-USApasses, but not as a country: three letters after the language read as an extended language subtag. A country takes two letters, as inen-US.- To check the parts against their lists, use the ISO 639-1 Language Code Validator and the ISO 3166-1 Alpha-2 Country Code Validator.
Features
- Checks the shape of BCP 47 language tags
- Language, script, region, variants and extensions
- Hyphens or underscores, capital or small letters
- Results as you type, with no button to press
- Runs in your browser, so nothing you type is sent anywhere