titleCase()
titleCase(
str):string
Converts a string to Title Case.
note
Capitalizes after spaces, hyphens, and underscores. Supports Unicode.
Parameters
str: string
The string to convert.
Returns: string
The string in Title Case.
Since
2.0.0
Also known as
title (Radashi) · titleCase (Modern Dash) · toTitleCase (Remeda) · ❌ (Lodash, es-toolkit, Ramda, Effect, Antfu)
Example
titleCase('hello world'); // => 'Hello World'
titleCase('hello-world'); // => 'Hello-World'
titleCase('HELLO WORLD'); // => 'Hello World'
titleCase('café résumé'); // => 'Café Résumé'
How it works?
Converts a string to Title Case. First letter of each word capitalized.
Conversion Examples
| Input | Output |
|---|---|
hello world | Hello World |
hello-world | Hello-World |
HELLO WORLD | Hello World |
café résumé | Café Résumé |
Process
Supports Unicode characters (accents, etc.).
Use Cases
Format headlines 📌
Capitalize the first letter of each word. Useful for formal titles and headers.
const headline = titleCase('the quick brown fox'); // 'The Quick Brown Fox'
Format navigation labels
Standardize menu item text from database values.
const menuItem = titleCase('user_settings'); // 'User Settings' (if it handles underscores)