Skip to main content

upperCase()

upperCase(str): string

Converts string to upper case with space-separated words.


Parametersโ€‹

str: string | null | undefinedโ€‹

The string to convert.


Returns: stringโ€‹

The upper cased string with words separated by spaces.


See Alsoโ€‹

String.toUpperCase() - MDN


Sinceโ€‹

2.0.0


Performanceโ€‹

O(n) โ€” charCode word splitting for short ASCII, regex for long/Unicode/emoji.


Also known asโ€‹

upperCase (Lodash, es-toolkit) ยท โŒ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)


Exampleโ€‹

upperCase('--Foo-Bar--');  // => 'FOO BAR'
upperCase('fooBar'); // => 'FOO BAR'
upperCase('__foo_bar__'); // => 'FOO BAR'

How it works?โ€‹

Converts string to space-separated uppercase words. Splits on case boundaries, underscores, hyphens, and emojis. Supports Unicode.

Conversion Examplesโ€‹

InputOutput
'--Foo-Bar--''FOO BAR'
'fooBar''FOO BAR'
'__foo_bar__''FOO BAR'

Processโ€‹


Use Casesโ€‹

Convert to upper case words ๐Ÿ“Œโ€‹

Convert string to space-separated uppercase words. Useful for headers, labels, or constants display.

upperCase('fooBar');       // => 'FOO BAR'
upperCase('__foo_bar__'); // => 'FOO BAR'
upperCase('--Foo-Bar--'); // => 'FOO BAR'

Format header textโ€‹

Format identifiers as uppercase display text.

const header = upperCase('contentType');
// => 'CONTENT TYPE'