# Converting strings to uppercase and lowercase with JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Feb 24, 2020, updated Oct 12, 2022. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-string-uppercase-lowercase

> Learn how to use the JavaScript built-in functions to convert strings to uppercase and lowercase.

In an [earlier article](https://attacomsian.com/blog/string-capitalize-javascript), we looked at different ways to capitalize the first letter of a string to uppercase in JavaScript. 

In this article, you'll learn how to uppercase or lowercase a string using JavaScript.

JavaScript provides two built-in functions for converting strings to uppercase and lowercase. Let us look at them.

## `toUpperCase()` Method

The `toUpperCase()` method transforms a string into uppercase letters in JavaScript. It doesn't change the original string and returns a new string equivalent to the string converted to uppercase.

Here is an example:

```javascript
const str = 'JavaScript World!'

// convert string to uppercase
const upperStr = str.toUpperCase()

// print the new string
console.log(upperStr)

// output: JAVASCRIPT WORLD!
```

## `toLowerCase()` Method

The `toLowerCase()` method does the opposite of the `toUpperCase()` method. It converts all characters of the string to lowercase:

```javascript
const str = 'JavaScript World!'

// convert string to lowercase
const lowerStr = str.toLowerCase()

// print the new string
console.log(lowerStr)

// output: javascript world!
```

Both these methods work in all modern browsers and are supported back to at least Internet Explorer 6.
