JavaScript String toUpperCase() Method

Last Updated : 15 Jan, 2026

The toUpperCase() method is used to convert all letters in a string to uppercase. It helps standardize text for comparison or display.

  • Converts all lowercase letters to uppercase.
  • Special characters and digits remain unchanged.
  • Letters that are already uppercase stay the same.
JavaScript
let text = "Hello World";

let result = text.toUpperCase();

console.log(result);

Syntax:

str.toUpperCase()

Parameters:

This method does not accept any parameter.

Return value:

The toUpperCase() method returns a modified version of the original string. It creates a new string with all letters converted to uppercase.

  • Returns a new string.
  • All lowercase letters are converted to uppercase.
  • The original string remains unchanged.

Example 1: In this example, we are converting the given string to uppercase.

JavaScript
let str = 'geeksforgeeks';
let string = str.toUpperCase();
console.log(string);

Example 2: In this example, the method toUpperCase() converts all the lower case alphabets to their upper case equivalents without affecting the special characters and the digits. 

JavaScript
// JavaScript String toUpperCase() method
// to convert string to Uppercase

// Original string
let str = 'It iS a 5r&:ampe@@t Day.'

// String converted to Upper Case
let string = str.toUpperCase();

console.log(string);

Example 3: In this example, we are creating an array of data with elements 'javascript', 'html', and 'css'. It uses map() and toUpperCase() to convert each element to uppercase.

JavaScript
let data = [ 'javascript', 'html', 'css' ];

let result = data.map(data => data.toUpperCase());

console.log(result);

Supported Browsers:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 3
  • Safari 1
Comment

Explore