The JavaScript string.toLowerCase() method
The toLowerCase() method returns a new string with every letter in lowercase. "HELLO".toLowerCase() gives "hello". It's the everyday tool for case-insensitive comparison and search — normalize both sides to lowercase, then compare. The original is never changed.
Overview
toLowerCase() converts every letter in a string to lowercase and returns a fresh string. It's the more commonly used of the case-conversion pair, mostly because lowercasing is the conventional way to normalize text for comparison.
The pattern shows up everywhere: matching a search term against content, comparing email addresses, checking a value against a list of keywords. Convert both sides to lowercase and case differences simply stop mattering — title.toLowerCase().includes(query.toLowerCase()) is a search filter in one line.
As with toUpperCase(), the original string is left alone, and a handful of international characters and locales need toLocaleLowerCase() for correct results. For ordinary text, this method is the reliable default.
Syntax
const lower = str.toLowerCase()
"HELLO".toLowerCase() // "hello"
Example
<pre id="out" style="font:15px ui-monospace,monospace"></pre>
<script>
const items = ['Apple', 'Banana', 'Cherry'];
const query = 'BAN';
const matches = items.filter(
item => item.toLowerCase().includes(query.toLowerCase())
);
document.getElementById('out').textContent = matches.join(', '); // Banana
</script>
Best practices
- Normalize both strings to lowercase before comparing or searching to ignore case.
- Use the return value; the original string is unchanged.
- Combine it with includes() for a simple case-insensitive search filter.
- Use
toLocaleLowerCase()when locale-specific casing matters.
Frequently asked questions
How do I convert a string to lowercase in JavaScript?
str.toLowerCase(), which returns a new all-lowercase string.How do I make a case-insensitive search?
text.toLowerCase().includes(term.toLowerCase()).