toLowerCase() is a method of String class in JavaScript which is used to convert an String alphabets into uppercase alphabets. It will only convert alphabets. If a string contains any special case in it or numbers or anything else, this method will not affect them; they will be the same as in the original text. This method creates a new string instance, and it does not take any argument. There are many built-in methods in Javascript just like reverse string etc.
Table of Contents
Why does a programmer need to use the toLowerCase() method?
Users enter data in variety of ways, sometimes it happens that the programmer needs data in lowercase. However, the entered user data can be in uppercase or even mixed case. That’s why a programmer needs to use toLowerCase() method to get data in the desired form.
Let’s have a look at examples.
Example #01
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<script>
str = "Hello! Welcome to JavaScript."
document.getElementById("demo").innerHTML = str.toLowerCase();
</script>
</body>
</html>
Output

Example #02
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<script>
str = "[email protected]"
document.getElementById("demo").innerHTML = str.toLowerCase();
</script>
</body>
</html>
Output

There are three other case related methods which are used in JavaScript to convert a string from one form to another form.
- toUpperCase(): this method converts the letters of a string to uppercase letters.
- toLocaleLowerCase(): this method is used to convert the letters of a string into lowercase letters according to the host’s current locale.
- toLocaleUpperCase(): this method is used to convert a string of characters to uppercase letters according to the host’s current locale.
Conclusion
In this article, we discussed the toLowerCase() method in JavaScript. This method is used to convert characters of a String from any case to lowercase. It is used because the user can provide the data in any form, and the there can be a need to convert it to the required format. Finally, we saw a few examples of this case too.
Read also: How to Use JavaScript += Operator?