Skip to content

toPascalCase

Converts a string to PascalCase format (first letter of each word in uppercase, no spaces).

Syntax

typescript
toPascalCase(str: string): string

Parameters

ParameterTypeDescription
strstringThe input string.

Returns

TypeDescription
stringThe string converted to PascalCase.

Example

typescript
toPascalCase("exemplo de string"); // "ExemploDeString"
toPascalCase("  teste pascal case  "); // "TestePascalCase"
toPascalCase(""); // ""

Notes

  • Throws TypeError if the argument is not a string.
  • Extra spaces are removed before conversion.

References

Released under the MIT License.