For Hosts Locale how to convert a string to lowercase letters in JavaScript?

To convert a string to lowercase letters in JavaScript, use the toLocaleLowerCase() method. This method converts characters to lowercase according to the host's locale, making it ideal for international applications.

Syntax

string.toLocaleLowerCase([locale])

Parameters

locale (optional): A string specifying the locale to use for conversion. If omitted, the host environment's current locale is used.

Basic Example

Here's how to use toLocaleLowerCase() to convert a string to lowercase:

<!DOCTYPE html>
<html>
   <body>
      <script>
         var str = "WELCOME TO TUTORIALSPOINT!";
         document.write("Original: " + str + "<br>");
         document.write("Lowercase: " + str.toLocaleLowerCase());
      </script>
   </body>
</html>
Original: WELCOME TO TUTORIALSPOINT!
Lowercase: welcome to tutorialspoint!

Locale-Specific Conversion

The method becomes especially useful with specific locales that have unique lowercase rules:

<!DOCTYPE html>
<html>
   <body>
      <script>
         var turkishStr = "?STANBUL";
         
         document.write("Turkish locale: " + turkishStr.toLocaleLowerCase('tr-TR') + "<br>");
         document.write("English locale: " + turkishStr.toLocaleLowerCase('en-US'));
      </script>
   </body>
</html>
Turkish locale: i?stanbul
English locale: i?stanbul

Difference from toLowerCase()

While toLowerCase() uses Unicode mapping, toLocaleLowerCase() respects locale-specific rules:

<!DOCTYPE html>
<html>
   <body>
      <script>
         var text = "MIXED TEXT 123!";
         
         document.write("toLowerCase(): " + text.toLowerCase() + "<br>");
         document.write("toLocaleLowerCase(): " + text.toLocaleLowerCase());
      </script>
   </body>
</html>
toLowerCase(): mixed text 123!
toLocaleLowerCase(): mixed text 123!

Key Points

  • The original string remains unchanged (strings are immutable)
  • Returns a new string with lowercase characters
  • Respects locale-specific conversion rules
  • Numbers and special characters remain unchanged

Conclusion

Use toLocaleLowerCase() when you need locale-aware string conversion. It's particularly important for international applications where different languages have specific lowercase rules.

Updated on: 2026-03-15T23:18:59+05:30

203 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements