Skip to content

titleCase

Converts a string to Title Case. Handles camelCase, PascalCase, kebab-case, snake_case, spaces, and mixed formats.

Available since v2.0.0

import { titleCase } from '@helpers4/string';
titleCase(str: string): string
ParameterTypeDescription
strstringThe string to convert

string — String in Title Case

Transforms a delimited string into Title Case.

titleCase('my-component-name')
// => 'My Component Name'

Also handles camelCase by splitting on uppercase transitions.

titleCase('queryItems')
// => 'Query Items'

View source on GitHub