Embark on my indie hacking journey: Documenting each step, sharing insights along the way

Home » Blog » Convert a String to Lower Case in JavaScript

Convert a String to Lower Case in JavaScript

Learn how to lowercase a string using JavaScript's "toLowerCase" built-in method.

As a developer, you may want to quickly get a lower case version of a string. I’ll show you how to do it using JavaScript in this article.

If you need it later, I also write another article about how to convert a string to upper case in JavaScript.

A built-in method to return a string to lower case in JS (toLowerCase)

In JavaScript, all strings have a built-in function to convert a string to lowercase.

This function is toLowerCase() and it don’t take any parameters. One particularity is that it will not update your string but return an updated version.

An example of how to lowercase in JavaScript

Let me show you a quick example with an uppercase string.

const lastName = 'THOMAS'

// Convert the uppercase string to lowercase

// Output: "thomas"

As mentioned previously, this function will not modify the original string. If you want to save your lower case result, you’ll need to create a new variable.

Here’s how you can do it!

const lastName = 'ThOmAs'
const lowerCaseLastName = lastName.toLowerCase()

// Output: "ThOmAs"

// Output: "thomas"

As you can see, the first variable stays unchanged.

Thanks for reading. Let’s connect!

➡️ I help you grow into Web Development, and I share my journey as a Nomad Software Engineer. Join me on Twitter for more. 🚀🎒

Gaël Thomas

Getting started on a solopreneur journey alongside my 9-5 🚧 Documenting my learnings and progress on Twitter (X) ✍️ Software Engineer 💻 My latest project: BooksByMood 📚

Post navigation