To change a string to uppercase or lowercase in JavaScript, call toUpperCase() or toLowerCase(). Both return a new string and leave the original untouched, because strings are immutable. These are the standard tools for normalising text before you compare it or show it to users.
For text in specific languages, the locale versions toLocaleUpperCase() and toLocaleLowerCase() apply that language's rules.
Always use the return value. A common beginner mistake is calling name.toUpperCase(); on its own line and expecting name to change.
Numbers and symbols are not affected, and calling the method on a non-string needs a conversion first:
Convert both sides to the same case before comparing.
For text that users type in many languages, localeCompare with a sensitivity option is more reliable:
A typical normalisation step for emails or tags is value.trim().toLowerCase().
JavaScript has no built-in capitalise method. Combine charAt() or at() with slice().
For title case, split into words and capitalise each:
In CSS you can display text in capitals without changing the data, using text-transform: uppercase, which is better for presentation-only needs.
Case rules are not the same in every language. In Turkish, the lowercase of I is the dotless ı, and the uppercase of i is İ. The locale methods accept a language tag.
Some conversions change the length of the string. The German letter ß becomes SS in uppercase:
Do not assume a round trip works: "STRASSE".toLowerCase() gives "strasse", not the original word.
Case conversion is often applied to many values at once. Use map() for lists and normalise keys when you build lookup tables.
When you convert user input for a search, convert the stored values once and reuse them rather than lowercasing inside every comparison of a long loop. Also remember that snake_case to camelCase conversions are string splits plus capitalisation, not a built-in feature:
No. It returns a new string, so assign the result to a variable.
Use str[0].toUpperCase() + str.slice(1), and check for an empty string first.
Lowercase both with toLowerCase() before comparing with ===, or use localeCompare with { sensitivity: "base" } for language-aware comparison.
toUpperCase() uses the default Unicode mapping, while toLocaleUpperCase(locale) follows the rules of the given language, for example Turkish dotted and dotless i.
toUpperCase() and toLowerCase() return new strings and never modify the original. Use them to normalise input and compare text without regard to case, write a small helper to capitalise words, and switch to the locale versions when the language has special case rules. CSS text-transform handles display-only changes.