How to Convert a String to Lower or Upper Case in Ruby? Last Updated : 28 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss how to convert a string to lower or upper case in Ruby. We can convert a string to lower or upper case using built-in methods provided in the Ruby language. Table of Content Using DowncaseUsing UpcaseUsing CapitalizeUsing DowncaseThe downcase method is used to convert the string to lowercase. Syntax: string.downcase In the below example, the string is converted to lowercase using the downcase method and store the result in the variable and at last output both the original and lowercase string. Ruby # Define a string string = "Geeks for Geeks" # Convert the string to lowercase using downcase method lowercase_string = string.downcase # Output the result puts "Original String: #{string}" puts "String in Lowercase: #{lowercase_string}" OutputOriginal String: Geeks for Geeks String in Lowercase: geeks for geeks Using UpcaseThe upcase method is used to convert the string to uppercase Syntax: string.upcase In the below example,the string is converted to uppercase using the uocase method and store the result in the variable and at last output both the original and uppercase string. Ruby # Define a string string = "Geeks For Geeks" # Convert the string to uppercase using upcase method uppercase_string = string.upcase # Output the result puts "Original String: #{string}" puts "String in Uppercase: #{uppercase_string}" OutputOriginal String: Geeks For Geeks String in Uppercase: GEEKS FOR GEEKS Using CapitalizeCapitalize is used to capitalize the first character of the string while converting the rest to lowercase. Syntax: string.capitalize In the below example,the string first letter is capitalized and the rest to lowercase. After which we store the result in the variable and output the both the original and capitalized string. Ruby # Define a string string = "GEEKS FOR GEEKS" # Capitalize the string using capitalize method capitalized_string = string.capitalize # Output the result puts "Original String: #{string}" puts "Capitalized String: #{capitalized_string}" OutputOriginal String: GEEKS FOR GEEKS Capitalized String: Geeks for geeks Comment More infoAdvertise with us Next Article How to Convert a String to Lower or Upper Case in Ruby? A abhaystriver Follow Improve Article Tags : Ruby Similar Reads How to convert String to Boolean in Ruby? In this article, we will learn how to convert string to Boolean in Ruby using various methods. Letâs understand each of them with the help of examples. Table of Content Converting string to Boolean using String#casecmpConverting string to Boolean using String#downcaseConvert string to Boolean using 3 min read How to convert uppercase string to lowercase using PHP ? Converting an uppercase string to lowercase means changing all capital letters in the string to their corresponding small letters. This is typically done using programming functions or methods to ensure uniformity in text formatting and comparison.Below we have some common approaches Table of Conten 2 min read How to convert lowercase string to uppercase using PHP ? A string is a storage object in PHP comprising characters, numbers or special symbols. Strings in PHP are case-sensitive. The interconversion between lower and upper case can be easily done using various in-built methods in PHP.Table of ContentUsing chr() method Using strtoupper() method Using mb_co 4 min read Shell Script to Convert a File Content to Lower Case or Upper Case Here we are going to see how to convert a file to lower case or upper case as specified by the user. We are going to write a POSIX compatible shell script which is going to give us the desired output after input of files such as sample.txt, a text file with a combination of lowercase, uppercase, dig 2 min read How To Convert Data Types in Ruby? Data type conversion is a frequent job in Ruby, particularly when working with various data types or integrating with other systems. Ruby offers a wide range of operators and methods for fluid data type conversion. Effective Ruby programming requires an understanding of these conversion methods. The 2 min read Like