sentenceCase()
sentenceCase(
str):string
Converts a string to Sentence case.
note
First character uppercase, rest lowercase. Alias behavior of capitalize.
Parametersโ
str: stringโ
The string to convert.
Returns: stringโ
The string in Sentence case.
See Alsoโ
Sinceโ
2.0.0
Also known asโ
โ (Lodash, es-toolkit, Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)
Exampleโ
sentenceCase('HELLO WORLD'); // => 'Hello world'
sentenceCase('hELLO wORLD'); // => 'Hello world'
sentenceCase('hello'); // => 'Hello'
How it works?โ
Converts a string to Sentence case. First character uppercase, rest lowercase.
Conversion Examplesโ
| Input | Output |
|---|---|
HELLO WORLD | Hello world |
hELLO wORLD | Hello world |
hello | Hello |
Processโ
Use Casesโ
Format titles ๐โ
Convert text to natural sentence case (first letter capitalized, rest lowercase). Useful for blog post titles or UI headings.
const title = sentenceCase('HELLO WORLD'); // 'Hello world'
Normalize error messagesโ
Standardize error message formatting for consistent UI.
const error = sentenceCase('INVALID_EMAIL_FORMAT'); // 'Invalid email format'