Skip to main content

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โ€‹

capitalize


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โ€‹

InputOutput
HELLO WORLDHello world
hELLO wORLDHello world
helloHello

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'