Aller au contenu principal

lowerFirst()

lowerFirst(str): string

Converts the first character of a string to lowercase.

remarque

Supports Unicode characters. Does not modify the rest of the string.


Parameters

str: string

The string to convert.


Returns: string

The string with the first character in lowercase.


See Also

upperFirst


Since

2.0.0


Also known as

lowerFirst (Lodash, es-toolkit) · ❌ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)


Example

lowerFirst('Hello'); // => 'hello'
lowerFirst('HELLO'); // => 'hELLO'
lowerFirst('Été'); // => 'été'

How it works?

Converts only the first character to lowercase. Rest of the string is preserved unchanged.

Examples

InputOutput
Hellohello
HELLOhELLO
Étéété

lowerFirst vs capitalize

Function'HELLO'
lowerFirsthELLO
capitalizeHello

lowerFirst only changes the first character.


Use Cases

Adjust casing 📌

Lowercase only the first character. Useful for specific formatting protocols (e.g., XML tags).

const tag = lowerFirst('Div'); // 'div'

Convert class names to instances

Transform PascalCase class names to camelCase variable names.

const varName = lowerFirst('UserService'); // 'userService'