docs/reference/compat/string/startCase.md
::: warning Use startCase from es-toolkit
This startCase function runs slower due to normalization logic for handling null or undefined.
Instead, use the faster and more modern startCase from es-toolkit.
:::
Converts a string to start case.
const startCased = startCase(str);
startCase(str)Use startCase when you want to convert a string to Start Case. Start Case is a naming convention where the first letter of each word is capitalized and separated by spaces.
import { startCase } from 'es-toolkit/compat';
// Convert regular string
startCase('hello world');
// Returns: 'Hello World'
// Keep words that are already uppercase
startCase('HELLO WORLD');
// Returns: 'HELLO WORLD'
// Convert hyphen-separated string
startCase('hello-world');
// Returns: 'Hello World'
// Convert underscore-separated string
startCase('hello_world');
// Returns: 'Hello World'
null or undefined are treated as empty strings.
import { startCase } from 'es-toolkit/compat';
startCase(null); // ''
startCase(undefined); // ''
str (string, optional): The string to convert to start case.(string): Returns the start case converted string.