← All languages
Swift function of the day
Random

String.lowercased

Return a lowercased copy of the string.

Description

The lowercased method returns a new string with all characters converted to their lowercase equivalents. It handles Unicode characters correctly, including locale-sensitive transformations.

The original string is not modified. For locale-aware lowercasing, use lowercased(with:) and pass a specific Locale.

lowercased is commonly used for case-insensitive comparisons or normalizing user input.

Example

let greeting = "Hello, World!"
print(greeting.lowercased())  // "hello, world!"

Reference