CyrefJS
CCyrefJS
فا
Back to documentation
String/Since 1.38.0

pascalCase

Converts a string into PascalCase by tokenizing it, capitalizing the first character of each word, lowercasing the remaining characters, and joining the words without separators.

pascalCase(value):string

Behavior

pascalCase first tokenizes the input into words. For each word, the first character is converted to uppercase and the remaining characters are converted to lowercase. The resulting words are then joined without a separator.

Tokenization

Word extraction is delegated to the internal tokenize utility. The exact word boundaries therefore depend on tokenize.

Casing rules

Every word starts with an uppercase character. All characters after the first one are converted to lowercase.

No separator

After each token is transformed, all tokens are joined directly with no separator.

Parameters

valuestringrequired

The string to convert to PascalCase.

Returns

string

The tokenized input converted to PascalCase.

Examples

01

Basic usage

Convert a space-separated phrase to PascalCase.

TypeScript
import { pascalCase } from "@cyref/js";

pascalCase("hello world");
// "HelloWorld"
02

Multiple words

Each word starts with an uppercase character and the words are joined together.

TypeScript
pascalCase("hello beautiful world");
// "HelloBeautifulWorld"
03

Mixed case

Each token is normalized to an uppercase first character followed by lowercase characters.

TypeScript
pascalCase("hello WoRLD TeST");
// "HelloWorldTest"
04

Single word

A single token is converted to PascalCase.

TypeScript
pascalCase("hELLO");
// "Hello"
05

Empty input

If tokenization produces no words, an empty string is returned.

TypeScript
pascalCase("");
// ""
06

Existing separators

The input is tokenized first, so the resulting words are joined without separators.

TypeScript
pascalCase("hello-world");
// "HelloWorld"
Built with@cyref/js·Official documentation