Our Salesforce organization recently implemented a customization for handling customer data. The customer service team needs a standardized format for customer names and emails in their records.
The customer service representatives often enter names and emails in mixed cases, leading to inconsistencies. The team wants to enforce a standardized format to avoid duplicates and errors during data processing.
To solve this, I used Apex methods to convert the Name to title case and the Email to lowercase. In the steps below, I will explain how to convert the string to lowercase and uppercase in Salesforce Apex.
Convert String to Lowercase and Uppercase In Salesforce Apex
To convert a String to lowercase, we use the built-in toLowerCase() method, and to convert a string to uppercase, we use the toUpperCase() method.
Convert String to Lowercase in Salesforce Apex
I will explain the string-to-lowercase conversion in Apex in the steps below. Now, navigate to the Salesforce developer console and follow the steps below.
- To open the anonymous execution window, click on the Debug > Open Execute Debug Window or press the shortcut keys “Ctrl+E.”
- Enter the code below in the anonymous window, select the checkbox, open it in Debug, and click the Execute button.
String name = 'Eva Adams';
System.debug('string in lowercase -' + name.toLowercase());- In the console log window, select debug only. The values will be converted to lowercase.

This way, we can convert the String to lowercase in Salesforce Apex by following the above steps.
Convert String to Uppercase in Salesforce Apex
To convert a string to Uppercase, we will use the apex function ToUppercase(). Now, navigate to the Salesforce developer console and follow the steps below.
- Open the anonymous window in the Salesforce developer console with the shortcut keys “Ctrl+E.”
- Enter the code below in the anonymous window, select the checkbox, open it in Debug, and click the Execute button.
String name = 'Henry Smith';
System.debug('String in Uppercase -' + name.toUppercase());- In the Console log window, select debug only. The values will be converted to uppercase.

In this way, we can convert the String to Uppercase in Salesforce Apex by following the above steps.
Convert List of Strings to Uppercase In Salesforce Apex
When you have to convert a list of strings to uppercase or lowercase, there is a different approach, which I have explained in the steps below.
- Open the Salesforce developer console and execute the anonymous window with the shortcut keys “Ctrl+E.“
- Enter the code below in the anonymous window, then select the checkbox Debug only and click the Execute button.
List<String> names = new List<String>{'john', 'henry', 'jeff'};
List<String> upperCaseNames = new List<String>();
for (String name : names) {
upperCaseNames.add(name.toUpperCase());
}
System.debug ('Uppercase Names: ' + upperCaseNames);In the above code, we have a list of strings. Then, a new, empty list named upperCaseNames is created to store the names converted to uppercase.
Within the For loop name.toUpperCase() converts the current name to uppercase. After this upperCaseNames.add(name.toUpperCase()) adds the uppercase version of the name to the upperCaseNames list.
- In the Console log window, select the checkbox Debug only. After this, you will see a list of strings converted to UpperCase.

By following the above code, you can convert the string to UpperCase in Salesforce Apex.
Conclusion
By now, you might have understood the method of string to uppercase and lowercase conversion in Salesforce Apex. In the above methods, we have learned to convert a single string to uppercase and lowercase. We also learned to convert a list of strings to uppercase and the exact steps that should be followed to convert a string to lowercase.
You may also like to read.
- Convert a String to Decimal in Salesforce Apex
- Convert String to Boolean in Salesforce Apex
- Convert String to ID in Salesforce Apex
- Convert String to Date in Salesforce Apex
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.