JavaScriptStrings

String.prototype.toLowerCase()

Returns a copy of the string converted to lowercase. Useful for comparisons and normalizing data.

Returns
A new string with the letters converted to lowercase.
Changes the original
No
On this page

Example

#
JavaScript
const email = '  Anna.Parker@Example.COM '

console.log(email.trim().toLowerCase())
console.log('ÉCOLE'.toLowerCase())
Console
anna.parker@example.com
école

Definition and usage

#

The toLowerCase() method returns a new string in which every uppercase letter is converted to lowercase. Characters that are not letters stay unchanged, and the original string remains as it was. The method takes no arguments.

It is the simplest way to normalize text before comparing or searching it. An email address typed as Anna@Example.com and anna@example.com is, in practice, the same address, so it is worth lowercasing it before saving or checking it.

Just like toUpperCase(), the method relies on universal Unicode rules. For languages with different rules, such as Turkish, there is toLocaleLowerCase(), which takes a language code.

Syntax

#
Syntax
string.toLowerCase()

More examples

#
Searching regardless of letter case
JavaScript
const courses = ['JavaScript for beginners', 'Advanced React', 'Python for beginners']
const query = 'REACT'

const results = courses.filter((course) => course.toLowerCase().includes(query.toLowerCase()))

console.log(results)
Console
['Advanced React']
A slug-style address
JavaScript
const title = 'Loops In JavaScript'
const slug = title.toLowerCase().replaceAll(' ', '-')

console.log(slug)
Console
loops-in-javascript

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Normalize data in one place, for example when saving an email address, instead of remembering to call toLowerCase() at every comparison.
  • When accents and language rules also matter for the comparison, localeCompare() is the better tool.

Related entries

#

Spotted a mistake or missing an example? Write to us.