JavaScript Reference Β· String
String.prototype.toLowerCase()
Reference for JavaScript String.prototype.toLowerCase(): convert a string to lower case using Unicode rules, with examples, edge cases and locale caveats.
The toLowerCase() method returns a copy of a string with its letters converted to lower case. Characters that have no lower-case form, such as digits, punctuation and most scripts without case, are left as they are.
It is the usual first step for case-insensitive comparisons, search keys and normalized identifiers such as e-mail addresses. It uses the Unicode default case mappings and ignores the user's locale; for language-specific rules, use toLocaleLowerCase(), which works like toLocaleUpperCase().
"Hello, World".toLowerCase(); // "hello, world"
Try it
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Syntax
string.toLowerCase()
This method takes no parameters.
Return value: a new string in which each character is converted to lower case according to the Unicode default mappings.
Exceptions: none for strings. Calling it on null or undefined throws a TypeError.
Usage notes
- Immutable: it returns a new string. The original stays unchanged, so use the return value.
- The length can change. Some characters lower-case to several code units, such as the capital dotted letter
Δ°, which becomes anifollowed by a combining dot. - Context rules exist. The Greek capital sigma becomes a final
Οat the end of a word andΟelsewhere, so"Ξ§ΞΞΞ£"gives"ΟΞ±ΞΏΟ". - Not locale-aware. Turkish and Lithuanian have special rules. Use
toLocaleLowerCase("tr")for those. - Case-insensitive comparison: converting both sides with
toLowerCase()works for many cases but is not perfect.localeCompare()withsensitivity: "base"orIntl.Collatoris better for user-visible sorting and matching. - Normalization is separate. Accented letters in composed and decomposed forms stay different; call
normalize()too if you compare text from different sources. - Non-strings: call
String(value).toLowerCase()when the value might not be a string, because numbers have no such method. - Cost: it creates a copy proportional to the string length, which is negligible except in very hot loops.
Browser support
String.prototype.toLowerCase() is supported in every browser.