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'