npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

easy-string-case

v1.0.2

Published

TypeScript library to convert strings between different case formats.

Downloads

17

Readme

easy-string-case

TypeScript library to convert strings between different case formats.


Main Features

  • Converts strings between the most common formats: camelCase, PascalCase, snake_case, kebab-case, dot.case, path/case, SCREAMING_SNAKE_CASE, COBOL-CASE, Title Case, Sentence case, UpperCamelCase.
  • Does not use any external dependencies. All processing is native and portable.
  • Supports input in any format: spaces, dashes, underscores, camelCase, PascalCase, etc.
  • Unicode-aware: supports international and accented characters.
  • Easy to use and test.

Installation

npm install easy-string-case

Basic Usage

import { StringCase } from 'easy-string-case';

StringCase.toCamelCase('hello world'); // 'helloWorld'
StringCase.toPascalCase('foo_bar-baz'); // 'FooBarBaz'
StringCase.toKebabCase('HelloWorld'); // 'hello-world'
StringCase.toSnakeCase('foo-bar baz'); // 'foo_bar_baz'
StringCase.toDotCase('snake_case-example'); // 'snake.case.example'
StringCase.toPathCase('FooBarBaz'); // 'foo/bar/baz'
StringCase.toScreamingSnakeCase('helloWorld'); // 'HELLO_WORLD'
StringCase.toCobolCase('snake_case'); // 'SNAKE-CASE'
StringCase.toTitleCase('mixedCASE input'); // 'MixedCASE Input'
StringCase.toSentenceCase('THIS_IS_A_TEST'); // 'This is a test'
StringCase.toUpperCamelCase('hello world'); // 'HelloWorld'

API

Main Methods

All methods are static and take a single argument: the string to convert.

StringCase.toCamelCase(str: string): string

Converts to camelCase. Example: "hello world""helloWorld"

StringCase.toPascalCase(str: string): string

Converts to PascalCase (UpperCamelCase). Example: "foo_bar-baz""FooBarBaz"

StringCase.toKebabCase(str: string): string

Converts to kebab-case. Example: "HelloWorld""hello-world"

StringCase.toSnakeCase(str: string): string

Converts to snake_case. Example: "foo-bar baz""foo_bar_baz"

StringCase.toDotCase(str: string): string

Converts to dot.case. Example: "snake_case-example""snake.case.example"

StringCase.toPathCase(str: string): string

Converts to path/case. Example: "FooBarBaz""foo/bar/baz"

StringCase.toScreamingSnakeCase(str: string): string

Converts to SCREAMING_SNAKE_CASE. Example: "helloWorld""HELLO_WORLD"

StringCase.toCobolCase(str: string): string

Converts to COBOL-CASE. Example: "snake_case""SNAKE-CASE"

StringCase.toTitleCase(str: string): string

Converts to Title Case. Example: "mixedCASE input""MixedCASE Input"

StringCase.toSentenceCase(str: string): string

Converts to Sentence case. Example: "THIS_IS_A_TEST""This is a test"

StringCase.toUpperCamelCase(str: string): string

Converts to UpperCamelCase (PascalCase). Example: "hello world""HelloWorld"


Advanced Examples

StringCase.toCamelCase('XML_http-request'); // 'xmlHttpRequest'
StringCase.toPascalCase('foo-bar_baz qux'); // 'FooBarBazQux'
StringCase.toKebabCase('some Text@ with spêcial#char'); // 'some-text-with-special-char'
StringCase.toSnakeCase('  hello  world  '); // 'hello_world'
StringCase.toDotCase('foo_bar.baz-qux'); // 'foo.bar.baz.qux'
StringCase.toPathCase('foo_bar.baz-qux'); // 'foo/bar/baz/qux'
StringCase.toScreamingSnakeCase('some Text@ with spêcial#char'); // 'SOME_TEXT_WITH_SPECIAL_CHAR'
StringCase.toCobolCase('foo-bar.baz_qux'); // 'FOO-BAR-BAZ-QUX'
StringCase.toTitleCase('foo-bar.baz_qux'); // 'Foo Bar Baz Qux'
StringCase.toSentenceCase('foo-bar.baz_qux'); // 'Foo bar baz qux'
StringCase.toUpperCamelCase('foo-bar.baz_qux'); // 'FooBarBazQux'

Implementation

The main logic is in two classes:

  • CommonCase: Normalizes the input string into an array of "words" using Unicode rules, common separators, and camelCase/PascalCase detection. This allows all methods to work correctly regardless of the original format.
  • StringCase: Exposes static methods to convert between the different formats, using CommonCase normalization.

No external dependencies are used. All code is pure and portable TypeScript.


Tests

The library includes unit tests with Jest for all methods and relevant cases. You can run them with:

npm run test

License

MIT