Skip to content

pascalCase

Import from @varavel/vdl-plugin-sdk/utils/strings.

function pascalCase(str): string;

Converts a string to PascalCase.

The input is first tokenized with words, allowing the function to accept a wide range of source formats such as snake_case, kebab-case, spaced strings, camelCase, or acronym-heavy identifiers.

Every token is normalized to an initial uppercase letter followed by a lowercased remainder. Empty or separator-only inputs return an empty string.

Parameters

Parameter Type Description
str string String to normalize.

Returns

string

The PascalCase representation of str.

Example

pascalCase("user_profile-name")
// "UserProfileName"