Skip to content
Tutorials Center
My learning

Topics

JavaScript Reference Β· String

String.prototype.toLocaleUpperCase()

Reference for JavaScript String.prototype.toLocaleUpperCase(): convert to upper case with language rules such as Turkish dotted i, with locale tag examples.

The toLocaleUpperCase() method returns a copy of a string converted to upper case using the rules of a given language or, if you pass none, the host's default locale. For most text the result equals toUpperCase(). The difference shows in languages with special case rules.

The classic example is Turkish, where the lower-case i has a dot and its upper-case form is Δ° (capital I with a dot), while the dotless Δ± becomes the plain I. A locale-blind conversion gets those wrong. The companion method toLocaleLowerCase() works the same way in the other direction.

JavaScript
"title".toLocaleUpperCase("tr"); // "TΔ°TLE"

Try it

JS Turkish versus the default

Press Run (or Ctrl + Enter) to see the console output here.

No output.

JS Lists of locales and errors

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Syntax

JavaScript
string.toLocaleUpperCase()
string.toLocaleUpperCase(locales)
Name Description
locales Optional. A BCP 47 language tag such as "tr" or "en-US", or an array of tags (the first supported one is used). If omitted, the host's current default locale is used.

Return value: a new string in upper case, following the rules of the chosen locale.

Exceptions: a RangeError if a locale tag is not structurally valid, and a TypeError if locales is an invalid kind of value.

Usage notes

  • Same as toUpperCase() for most languages. The two differ mainly for Turkish (tr), Azerbaijani (az) and Lithuanian (lt).
  • Default locale hazard. Without an argument, the result depends on the machine's settings, so the same code can behave differently for different users. This is the classic "Turkish i" bug: a program that compares "title".toLocaleUpperCase() with "TITLE" fails on a Turkish system.
  • Use it for display, not for keys. For identifiers, protocol keywords or comparisons, prefer the locale-independent toUpperCase(); for text shown to a person in their language, pass their locale.
  • Pass a tag explicitly when you know the language, for example from the document's lang attribute or from navigator.language.
  • Length can change here too, as with ß becoming SS.
  • Fallbacks: if none of the requested locales is supported, the default locale is used.
  • Immutable: the original string is not changed.
  • Related API: Intl.Locale and Intl.getCanonicalLocales() can validate and normalize tags before you use them.

Browser support

String.prototype.toLocaleUpperCase() is supported in every browser. The quality of language-specific rules depends on the Unicode and locale data of the browser, so check a compatibility table if you rely on a rarely used locale.