Skip to content
Home » How to Convert String to Lower Case using JavaScript

How to Convert String to Lower Case using JavaScript

In this tutorial let’s learn about How to Convert String to Lower Case using JavaScript.

JavaScript allows us to transform strings in a variety of ways. We may lower case the characters in native JavaScript by using the toLowerCase() prototype method or the toLocaleLowerCase() prototype which converts lower case. The strings in JavaScript can be converted into Lower Case using any of the methods given below.

  • toLowerCase()
  • toLocaleLowerCase()

Convert String to Lower Case using toLowerCase() Method in JavaScript

The toLowerCase() method in JavaScript turns a string to lowercase letters. ToLowerCase() does not change the original string. Instead, it returns a copy of the string with the letters changed to lowercase. This approach has no effect on any special letters, numbers, or alphabets that are already in lower case.

Syntax:

str.toLowerCase()

Code Example :

let str = 'Similar Geeks';
var final  = str.toLowerCase();

console.log(final);

Output :

similar geeks

Convert String to Lower Case using toLocaleLowerCase() Method using JavaScript

toLocaleLowerCase() is a string method in JavaScript that is used to transform a string to lowercase based on locale. Because the toLocaleLowerCase() method is a String object method, it must be invoked through a specific instance of the String class.

  • The toLocaleLowerCase() method uses the current locale to convert a string to lowercase letters.
  • The locale is determined by the browser’s language settings.
  • The toLocaleLowerCase() method does not affect the original string.
  • Except for locales that contradict with the usual Unicode case mappings, toLocaleLowerCase() delivers the same output as toLowerCase() (such as Turkish).

Syntax:

str.toLocaleLowerCase()

Code Example :

let str = 'Similar @#Geeks';
var final  = str.toLocaleLowerCase();

console.log(final);

Output :

similar @#geeks

Convert Non String Object to Lower Case using JavaScript

If we wish to convert a Date to lower case, even if it is a non-String object, we can use the toLowerCase() or toLocaleLowerCase() methods, which are both designed to operate with any value type.

Let’s look at an example of how to convert Date() to lower case:

Code Example :

var actual_date = new Date();
var string_date = new Date().toString().toLowerCase();

console.log("Normal Date Format > "+actual_date);
console.log("Lower Case Date Format > "+string_date);

Output :

Normal Date Format > Tue Feb 08 2022 15:57:44 GMT+0530 (India Standard Time)
Lower Case Date Format > tue feb 08 2022 15:57:44 gmt+0530 (india standard time)

Conclusion

In this tutorial we have learnt different ways to convert a string to lower case characters using JavaScript methods. The mostly commonly used methods is to LowerCase().

Similar Posts:

How to Remove Spaces From a String in JavaScript
How to Generate Random String using JavaScript