What is pascalcase?
The pascalcase npm package is a simple utility that converts strings into PascalCase format. This can be useful for formatting variable names, class names, or other identifiers in programming to adhere to PascalCase naming conventions.
What are pascalcase's main functionalities?
String Conversion to PascalCase
Converts a given string to PascalCase by splitting the string into words, capitalizing the first letter of each word, and then concatenating them without spaces.
"hello world".split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join('')
Other packages similar to pascalcase
camelcase
The camelcase package converts strings to camelCase format. It is similar to pascalcase but the first letter of the resulting string is lowercase, which is the main difference between camelCase and PascalCase.
change-case
This is a more comprehensive string transformation library that includes various case conversion methods including pascalCase, camelCase, snake_case, and more. It offers more functionality compared to the single-purpose pascalcase package.
uppercamelcase
Similar to pascalcase, uppercamelcase converts strings to UpperCamelCase (another name for PascalCase). The functionality is very similar, but the package names suggest a different naming convention for the same string transformation.
pascalcase

Convert a string to pascal case (upper camelcase).
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install
Install with npm (requires Node.js >=14):
$ npm install --save pascalcase
Prerequisites
Requires Node.js version >= 14.
Usage
import pascalcase from 'pascalcase';
import { pascalcase } from 'pascalcase';
console.log(pascalcase('a'));
console.log(pascalcase('foo bar baz'));
console.log(pascalcase(' foo bar baz '));
console.log(pascalcase('foo_bar-baz'));
console.log(pascalcase('foo.bar.baz'));
console.log(pascalcase('foo/bar/baz'));
console.log(pascalcase('foo[bar)baz'));
console.log(pascalcase('#foo+bar*baz'));
console.log(pascalcase('$foo~bar`baz'));
console.log(pascalcase('_foo_bar-baz-'));
console.log(pascalcase('foo 2 bar 5 baz'));
console.log(pascalcase('foo2bar5baz'));
Uppercase character sequences
If you wish to preserve upper case character sequences, you may pass an options object with the preserveConsecutiveUppercase
option set to true
:
console.log(pascalcase('The IRS Is Mean'));
console.log(pascalcase('The IRS Is Mean', { preserveConsecutiveUppercase: true }));
console.log(pascalcase('We saw a UFO'));
console.log(pascalcase('We saw a UFO', { preserveConsecutiveUppercase: true }));
Options
All options are passed to sindresorhus/camelcase, please visit that project to learn about all available options.
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb
Related projects
You might also be interested in these projects:
- ansi-colors: Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in… more | homepage
- justified: Wraps words to a specified length and justifies the text in each line. | homepage
- randomatic: Generate randomized strings of a specified length using simple character sequences. The original generate-password. | homepage
- word-wrap: Wrap words to a specified length. | homepage
Author
Jon Schlinkert
License
Copyright © 2021, Jon Schlinkert.
Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on December 29, 2021.