String.prototype.toLowerCase
Converts a string to lowercase.
Available since: ES1
Syntax
str.toLowerCase()Return value
stringA new string in lowercase.
Examples
All letters become lowercase:
console.log('Hello, World'.toLowerCase());Output:
hello, worldA case-insensitive comparison:
const input = 'ANNA@Example.com';
console.log(input.toLowerCase() === 'anna@example.com');Output:
trueNotes
Strings in JavaScript are immutable: the method returns a new string and the original stays the same.
See also
- String.prototype.toUpperCase — Converts a string to uppercase.
- String.prototype.localeCompare — Compares strings by language rules — for alphabetical sorting.
Related recipes
In the tutorial
- String methods — Useful string methods in JavaScript: finding a position, reading characters, padStart, repeat, split and join, method chains.