For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/string/upperCase.md.

upperCase es-toolkit

Converts a string to a format where all letters are uppercase and words are separated by spaces.

const result = upperCase(str);

Usage

upperCase(str)

Use upperCase when you want to convert a string to uppercase notation. It converts each word to uppercase and connects words with spaces. It can handle strings in various notations like camelCase, kebab-case, snake_case, etc.

import { upperCase } from 'es-toolkit/string';

// Convert camelCase to uppercase notation
upperCase('camelCase');
// Returns: 'CAMEL CASE'

// Convert strings that already have spaces
upperCase('some whitespace');
// Returns: 'SOME WHITESPACE'

// Convert kebab-case to uppercase notation
upperCase('hyphen-text');
// Returns: 'HYPHEN TEXT'

// Handle strings with consecutive uppercase letters
upperCase('HTTPSRequest');
// Returns: 'HTTPS REQUEST'

Useful when converting various naming conventions to a unified uppercase format:

// Unify various key names from API responses
const apiKeys = ['user_name', 'firstName', 'email-address', 'phoneNumber'];
const upperCaseKeys = apiKeys.map(key => upperCase(key));
console.log(upperCaseKeys);
// ['USER NAME', 'FIRST NAME', 'EMAIL ADDRESS', 'PHONE NUMBER']

// Use when displaying file names
const fileName = 'profile_image_thumbnail.jpg';
const displayName = upperCase(fileName.replace('.jpg', ''));
console.log(displayName); // 'PROFILE IMAGE THUMBNAIL'

Parameters

strstringrequired

The string to convert to uppercase notation.

Returns

Returns a string with each word converted to uppercase and separated by spaces.

string
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.