pascalCase()
pascalCase(
str):string
Converts a string to PascalCase.
remarque
Handles kebab-case, snake_case, camelCase, and space-separated strings.
Delegates word parsing to camelCase for consistency.
Parameters
str: string
The string to convert.
Returns: string
The string in PascalCase.
See Also
Since
2.0.0
Performance
O(n) where n is string length. Single pass via camelCase + O(1) uppercase.
Also known as
pascal (Radashi) · pascalCase (es-toolkit, Modern Dash) · ❌ (Lodash, Remeda, Ramda, Effect, Antfu)
Example
pascalCase('hello-world'); // => 'HelloWorld'
pascalCase('background_color'); // => 'BackgroundColor'
pascalCase('foo bar'); // => 'FooBar'
pascalCase('helloWorld'); // => 'HelloWorld'
pascalCase('XMLHttpRequest'); // => 'XmlHttpRequest'
How it works?
Converts a string to PascalCase format. Each word capitalized, no separators.
Conversion Examples
| Input | Output |
|---|---|
hello-world | HelloWorld |
background_color | BackgroundColor |
foo bar | FooBar |
helloWorld | HelloWorld |
Relationship with camelCase
PascalCase = camelCase with first letter uppercase.
Use Cases
Generate component names 📌
Convert strings to PascalCase for React component names or class definitions.
Essential for scaffolding tools.
const component = pascalCase('nav_bar'); // 'NavBar'