capitalize es-toolkit
Converts the first character of a string to uppercase and the remaining characters to lowercase.
Usage
capitalize(str)
Use capitalize when you want to make only the first letter uppercase and convert the rest to lowercase. It's useful for normalizing names or titles.
It also handles empty strings and single character strings correctly.
You can use it to normalize user input or create titles.
Parameters
strstringrequired
The string to capitalize the first character.
Returns
Returns a new string with the first character capitalized and the rest in lowercase.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.