String.prototype.toLowerCase()
toLowerCase() string · Added in vES1 · Updated March 13, 2026 · String Methods The toLowerCase() method returns a new string with all alphabetic characters converted to lowercase. This is essential for normalizing user input, performing case-insensitive comparisons, and standardizing data for storage or comparison.
Syntax
str.toLowerCase()
Parameters
toLowerCase() takes no parameters.
String Immutability
Remember that strings in JavaScript are immutable. This means toLowerCase() does not modify the original string—it returns a brand new one:
const original = "HELLO";
const lower = original.toLowerCase();
console.log(original); // "HELLO" (unchanged)
console.log(lower); // "hello" (new string)
This behavior is consistent across all string methods and is a fundamental concept to understand.
Examples
Basic conversion
const greeting = "HELLO World";
console.log(greeting.toLowerCase()); // "hello world"
const acronym = "NASA";
console.log(acronym.toLowerCase()); // "nasa"
Case-insensitive comparison
For reliable case-insensitive matching, normalize both strings:
function isAdmin(role) {
return role.toLowerCase() === 'admin';
}
console.log(isAdmin("ADMIN")); // true
console.log(isAdmin("Admin")); // true
console.log(isAdmin("admin")); // true
console.log(isAdmin("user")); // false
Handling special characters and numbers
toLowerCase() preserves numbers and special characters while converting only letters:
const mixed = "Hello123! @World";
console.log(mixed.toLowerCase()); // "hello123! @world"
const email = "USER@EXAMPLE.COM";
console.log(email.toLowerCase()); // "user@example.com"
const path = "/USERS/DOCUMENTS/file.txt";
console.log(path.toLowerCase()); // "/users/documents/file.txt"
Locale-Safe Transformations
For Turkish, Azerbaijani, and certain other locales, standard toLowerCase() produces incorrect results. The Turkish dotted “İ” (U+0130) and dotted “i” should not become a regular “i”:
// Standard toLowerCase - problematic for Turkish
console.log("İSTANBUL".toLowerCase()); // "istanbul" (wrong)
// Use toLocaleLowerCase for locale-specific conversion
console.log("İSTANBUL".toLocaleLowerCase('tr-TR')); // "istanbul" (correct)
console.log("İSTANBUL".toLocaleLowerCase('en-US')); // "istanbul"
When in doubt about international users, prefer toLocaleLowerCase() with an explicit locale or let JavaScript use the user’s default locale.
Common Patterns
Normalize and trim user input
function normalizeInput(input) {
return input?.trim().toLowerCase() ?? '';
}
console.log(normalizeInput(" HELLO ")); // "hello"
console.log(normalizeInput(null)); // ""
Create URL-friendly slugs
function slugify(title) {
return title
.toLowerCase()
.trim()
.replace(/\s+/g, '-')
.replace(/[^\w-]/g, '');
}
console.log(slugify("JavaScript Tips & Tricks")); // "javascript-tips-tricks"
Key Behaviors
- Returns a new string—original remains unchanged (immutability)
- Only affects Unicode letters; numbers, symbols, and whitespace are preserved
- Works across all Unicode planes, including emoji
- For locale-specific rules, use
toLocaleLowerCase(locale)
See Also
- string::localeCompare — Compare strings locally
- string::trim — Remove whitespace