Skip to main content Accessibility Feedback

Converting strings to uppercase and lowercase with vanilla JavaScript

JavaScript provides two helpful functions for converting text to uppercase and lowercase.

String.toLowerCase() converts a string to lowercase, and String.toUpperCase() converts a string to uppercase.

var text = 'This sentence has some MIXED CASE LeTTeRs in it.';

// returns 'this sentence has some mixed case letters in it.'
var lower = text.toLowerCase();

// returns 'THIS SENTENCE HAS SOME MIXED CASE LETTERS IN IT.'
var upper = text.toUpperCase();

Both methods work in all modern browsers, and are supported back to at least IE6.

Tomorrow, we’ll look at how to convert text to title case (the first letter of every word capitalized).


🚀 Make 2018 the year you master JavaScript! My pocket guides and mini courses are short, focused, and made for beginners. You can do this!

Have any questions or comments about this post? Email me at chris@gomakethings.com or contact me on Twitter at @ChrisFerdinandi.

Get Daily Developer Tips