Skip to content
  • (+91) 9409548155
  • support@appdividend.com
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
Menu
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
JavaScript

JavaScript String toLowerCase() Method

  • 09 Aug, 2025
  • Com 0
JavaScript String toLowerCase() Method

JavaScript toLowerCase() is a built-in String prototype function that returns a new string with all alphabetic characters converted to lowercase based on the host environment’s current locale configuration.

Converting an input string into a lowercase in JavaScript

let str = "Cristiano Ronaldo is a Portuguese professional footballer";

lowerStr = str.toLowerCase();

console.log(lowerStr);

// Output: cristiano ronaldo is a portuguese professional footballer

Strings are immutable, so it does not modify the original string. It raises TypeError if you attempt to call on null or undefined.

Syntax

string.toLowerCase()

Parameters

None: It does not take any arguments.

String with all uppercase letters

String with all uppercase letters converted to lowercase in JSLet’s take a single string that contains all the uppercase letters and convert it into lowercase.

let single_str = "CRISTIANO";

lower_single_str = str.toLowerCase();

console.log(lower_single_str);

// Output: cristiano

Mixed cases with numbers and special characters

Mixed cases with numbers and special characters in JS

If a string contains uppercase, lowercase, numbers, and special characters, the toLowerCase() method does not change already lowercase characters, numbers, and special characters.

let mixed_str = 'Cristiano Ron@ldo CR7';

mixed_lowercase = mixed_str.toLowerCase();

console.log(mixed_lowercase);

// Output: cristiano ron@ldo cr7

As you can see from the output, it only affects alphabetic characters, so digits and special characters remain unchanged.

Converting all strings of the array to lowercase

To convert an array of strings to lowercase, use the combination of array.map() and string.toLowerCase() methods.

Converting all strings of the array to lowercase in JavaScript

let array_of_strings = [
  'MILLIE',
  'NOAH',
  'FINN',
  'SADIE'
]

let lower_case_array = array_of_strings.map((str) => str.toLowerCase())

console.log(lower_case_array)

// Output: [ 'millie', 'noah', 'finn', 'sadie' ]

In this code, we used an array.map() function that transforms an array of elements from uppercase to lowercase using the str.toLowerCase() and returns a new array containing all the lowercase elements.

Unicode characters

convert Unicode characters to lowercase in JS

When you pass unicode characters like accented letters, it converts these letters to lowercase, but it does not always follow the locale-specific rules.

unicode_str = "ÄÖÜ";

lower_unicode_str = unicode_str.toLowerCase();

console.log(lower_unicode_str);

// Output: äöü

Locale-specific conversion

When it comes to proper locale-specific translation (like Turkish dotted/undotted i or some Greek letters), the toLocaleLowerCase() method ensures the proper casing according to the given language. 

The toLowerCase() function is not the correct function to do the job in this scenario.

const str = "Istanbul İZMİR";

// Turkish locale lowercase
console.log(str.toLocaleLowerCase('tr'));

// Output: ıstanbul izmir

// Default (English-style) lowercase
console.log(str.toLowerCase());

// Output: istanbul i̇zmi̇r

You can see that both methods are returning different outputs.

TypeError: number.toLowerCase is not a function

If you apply the toLowerCase() method on Numbers (Other than string objects), it throws TypeError: number.toLowerCase is not a function error. 

const number = 1921

number_to_lower = number.toLowerCase()

console.log(number_to_lower)

// TypeError: number.toLowerCase is not a function

Type coercion

To prevent the toLowerCase is not a function type of error, you can convert that number object into a string object using the “toString()” method and then apply the toLowerCase() method.

const number = 1921
const bool = true

console.log(number.toString().toLowerCase())

// Output: 1921

console.log(String(bool).toLowerCase());

// Output: true

In the above, we not only used a number but also a boolean value, converted both values to a string, and then converted the string to lowercase.

Since the number has digits, it is unchanged. Also, a boolean value is represented by “true”, so it does not change either.

TypeError: Cannot read properties of null

What if you apply a str.toLowerCase() method on a null value? Well, it throws TypeError: Cannot read properties of null error because null is not a string object. It fails immediately.

const obj = null;

console.log(obj.toLowerCase()); // This will throw an error because obj is null

// TypeError: Cannot read properties of null (reading 'toLowerCase')
To fix this error, we can check if obj is a string before calling the toLowerCase() method.
const obj = null;

// To fix this, we can check if obj is string

if (typeof obj === 'string') {
  console.log("Object is a string");
}
else {
  console.log("Object is not a string");
}

// Output: Object is not a string

And we handled the possible error efficiently.

Post Views: 48
Share on:
Krunal Lathiya

With a career spanning over eight years in the field of Computer Science, Krunal’s expertise is rooted in a solid foundation of hands-on experience, complemented by a continuous pursuit of knowledge.

JavaScript String toUpperCase() Method
Python List extend() Method

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Address: TwinStar, South Block – 1202, 150 Ft Ring Road, Nr. Nana Mauva Circle, Rajkot(360005), Gujarat, India

Call: (+91) 9409548155

Email: support@appdividend.com

Online Platform

  • Pricing
  • Instructors
  • FAQ
  • Refund Policy
  • Support

Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of services

Tutorials

  • Angular
  • React
  • Python
  • Laravel
  • Javascript
Copyright @2024 AppDividend. All Rights Reserved
Appdividend