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 🙏

© 2026 – Pkg Stats / Ryan Hefner

str-case-converter

v1.1.1

Published

A utility for converting strings between different case formats.

Readme

str-case-converter

A lightweight utility for converting strings between different case formats. Automatically detects input case format or lets you specify it explicitly.

Installation

npm install str-case-converter

Usage

import { convertString } from 'str-case-converter';

// Basic usage (auto-detects source case)
convertString.toCamel('hello-world'); // 'helloWorld'
convertString.toSnake('helloWorld'); // 'hello_world'
convertString.toPascal('hello_world'); // 'HelloWorld'
convertString.toKebab('HelloWorld'); // 'hello-world'
convertString.toConstant('helloWorld'); // 'HELLO_WORLD'
convertString.toTitle('hello-world'); // 'Hello World'
convertString.toDot('Hello World'); // 'hello.world'
convertString.toNo('helloWorld'); // 'hello world'
convertString.toSentence('hello_world'); // 'Hello world'
convertString.toPath('Hello World'); // 'hello/world'

// Utility methods
convertString.detect('helloWorld'); // 'camel'
convertString.toArray('hello-world'); // ['hello', 'world']
convertString.capitalize('hello'); // 'Hello'

// Specify source case for better performance/control
convertString.toCamel('hello-world', 'kebab'); // 'helloWorld'
convertString.toSnake('hello-world', 'kebab'); // 'hello_world'

Supported Cases

  • camelCase: 'helloWorld'
  • PascalCase: 'HelloWorld'
  • snake_case: 'hello_world'
  • kebab-case: 'hello-world'
  • CONSTANT_CASE: 'HELLO_WORLD'
  • Title Case: 'Hello World'
  • dot.case: 'hello.world'
  • no case: 'hello world'
  • Sentence case: 'Hello world'
  • path/case: 'hello/world'

Features

  • Auto-detection of input case format
  • Optional source case specification
  • Handles mixed cases, unknown formats and non string types
  • No dependencies
  • Lightweight and efficient
  • ESM support

API

Main Methods

All conversion methods accept two parameters:

  • str: string - The string to convert
  • sourceCase?: string - Optional source case type for better performance/control
convertString.toCamel(str, sourceCase?)     // Converts to camelCase
convertString.toPascal(str, sourceCase?)    // Converts to PascalCase
convertString.toSnake(str, sourceCase?)     // Converts to snake_case
convertString.toKebab(str, sourceCase?)     // Converts to kebab-case
convertString.toConstant(str, sourceCase?)  // Converts to CONSTANT_CASE
convertString.toTitle(str, sourceCase?)     // Converts to Title Case
convertString.toDot(str, sourceCase?)       // Converts to dot.case
convertString.toNo(str, sourceCase?)        // Converts to no case
convertString.toSentence(str, sourceCase?)  // Converts to Sentence case
convertString.toPath(str, sourceCase?)      // Converts to path/case

Utility Methods

convertString.detect(str); // Returns the case type or null if unknown
convertString.toArray(str); // Converts string to array of words
convertString.capitalize(str); // Capitalize the first character

Tips

  • You can destructure the method you need to avoid calling the object.
  • Ultimately, you can pass anything you want as arguments.
  • The first argument will always be converted into a string.
  • The second argument will allow you to skip the detect function no matter what and will be compared to valid case names
// destructuring
const { toCamel } = convertString;
['hello-world', 'foo-bar'].map((str) => toCamel(str));

// using unknown case format
toCamel('AR3_y0u-GONNA break Yet?', null); // 'ar3Y0uGonnaBreakYet?'

// converting other types
convertString.toConstant(undefined, {}); // 'UNDEFINED'

// control the output with the case format
convertString.toSnake(
    'If I useTitle-case as an argument, it will only remove spaces/uppercases',
    'title'
);
// if_i_usetitle-case_as_an_argument,_it_will_only_remove_spaces/uppercases

License

MIT

Issues

If you find a bug or have a suggestion, please file an issue on GitHub.