In Java, toLowerCase(locale) returns a new String in which every character is converted to lowercase using the rules of the given locale. The original string is immutable and stays as it was.
Use it to normalize text before storing or comparing, for example email addresses or command names. For program logic, pass Locale.ROOT (or Locale.ENGLISH) so the result does not depend on the user's language settings.
toLowerCase() is an instance method of java.lang.String, available since JDK 1.0. Call it on a string, as in text.toLowerCase(...); calling it on a null reference throws NullPointerException. Strings are immutable, so it never changes the original: it returns a new String (or the same one when nothing changes). Keep the result.
Syntax
Pass a locale explicitly; the overload without arguments uses the JVM default locale.
The Turkish pitfall: in a Turkish locale, the capital I lowercases to a dotless i (U+0131), not i. Code such as "TITLE".toLowerCase().equals("title") then fails on a machine set to Turkish. Locale.ROOT always maps I to i.
Library declarations
java
public String toLowerCase();
public String toLowerCase(Locale locale);
Parameters
Parameter
Description
locale
Optional. The case-mapping rules to use. Without it, Locale.getDefault() is used.
Return Value
Return Value
Description
String
The lowercase text. It may be longer than the original for a few special characters.
Java Examples
Example 1 — Convert a Title to Lowercase
Lowercase mixed text and confirm that the original is unchanged.
java
import java.util.Locale;
public class ToLowerCaseBasic {
public static void main(String[] args) {
String title = "Hello WORLD 123";
String lower = title.toLowerCase(Locale.ROOT);
System.out.println(lower);
System.out.println(title);
}
}
Output
hello world 123
Hello WORLD 123
How It Works
Letters change, the rest stays. Every capital becomes lowercase; the digits 123 and the spaces are copied as they are.
A locale-neutral result.Locale.ROOT gives the same output on every machine, whatever its language settings.
Immutability in action.title still prints "Hello WORLD 123"; the lowercase text exists only in lower.
Example 2 — Normalize Email Addresses Before Comparing
Users type addresses with random capitals; lowercase both sides before checking.
equals is case-sensitive.'A' and 'a' are different chars, so the raw comparison fails.
Normalize, then compare. Lowercasing the typed address with Locale.ROOT makes it identical to the stored one.
A shortcut for one-off checks.equalsIgnoreCase reaches the same answer without creating a new string; lowercasing is better when you store the normalized key.
Example 3 — Lowercasing Can Change the Length
The capital I with dot above (U+0130) becomes two chars in Locale.ROOT.
before: 1 char
after: 2 chars
first: i
second: U+307
How It Works
A special Unicode rule. Outside Turkish and Azeri locales, U+0130 lowercases to a plain i followed by a combining dot above.
One char becomes two. The result has length 2, so an index into the original string may not fit the lowercase copy.
Inspect the second char.Integer.toHexString shows the combining dot as 307 (U+0307), keeping the output ASCII.
Frequently Asked Questions
Without a locale, Java uses the default locale of the machine. In Turkish, I lowercases to a dotless i, which breaks comparisons. Locale.ROOT gives the same result everywhere.
No. Strings are immutable. It returns a new lowercase String, so assign the result: s = s.toLowerCase(Locale.ROOT);
For a single comparison, equalsIgnoreCase() is simpler. Use toLowerCase(Locale.ROOT) when you want to store or look up a normalized key.
Yes, rarely. For example U+0130 becomes two chars in Locale.ROOT. Do not reuse indexes across the conversion.
For case mapping both use the language-neutral rules, so I becomes i. Locale.ROOT expresses "no particular language" most clearly.