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

text-case-converter

v1.0.4

Published

[DEPRECATED] A modern TypeScript library to convert strings between various case formats (camelCase, PascalCase, snake_case, etc.).

Downloads

13

Readme

⚠️ DEPRECATED

This package is no longer maintained.

Please use lodash (lodash.camelcase, lodash.snakecase, etc.) instead. See: https://lodash.com/docs


Original README below:


text-case-converter

npm version MIT License minzipped size

A modern TypeScript library to convert strings between various case formats (camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE).


✨ Features

  • Convert between camelCase, PascalCase, snake_case, kebab-case, and CONSTANT_CASE
  • Handles acronyms and numbers correctly
  • Smart word boundary detection (e.g. parseJSONDataparse_json_data)
  • Zero runtime dependencies
  • Fully typed and tree-shakable
  • Thoroughly tested with Vitest
  • Strict error handling: throws TypeError for invalid input
  • Modern dev experience: ESLint, Prettier, GitHub Actions, JSDoc
  • Dual ESM + CJS build outputs for maximum compatibility
  • Clean, minimal API for clarity and consistency

🚀 Why use text-case-converter?

Most string case conversion libraries fall short when it comes to:

  • ❌ Incorrect acronym handling (XMLHttpRequestx_m_l_http_request)
  • ❌ Weak edge-case support for numbers (getUser2FAget_user2_f_a)
  • ❌ No input validation — silently processes undefined or objects
  • ❌ Missing or inaccurate TypeScript types
  • ❌ Bloated dependencies or lack of tree-shaking support

text-case-converter solves these problems:

  • ✅ Smart word segmentation and acronym awareness
  • ✅ Strict input handling (throws TypeError)
  • ✅ Predictable, idempotent transformations
  • ✅ TypeScript-first design, no need for @types/...
  • ✅ Lightweight and tree-shakable
  • ✅ Fully tested, including edge cases
  • ✅ ESM + CJS builds for universal compatibility

📦 Installation

npm install text-case-converter

📚 Usage

import {
  toCamelCase,
  toPascalCase,
  toSnakeCase,
  toKebabCase,
  toConstantCase,
} from 'text-case-converter';

console.log(toCamelCase('hello world')); // "helloWorld"
console.log(toPascalCase('hello world')); // "HelloWorld"
console.log(toSnakeCase('hello world')); // "hello_world"
console.log(toKebabCase('hello world')); // "hello-world"
console.log(toConstantCase('hello world')); // "HELLO_WORLD"

console.log(toCamelCase('XMLHttpRequest')); // "xmlHttpRequest"
console.log(toSnakeCase('myNASAProject')); // "my_nasa_project"
console.log(toConstantCase('parseJSONData')); // "PARSE_JSON_DATA"

🧪 API Reference

Types

export type CaseType = 'camelCase' | 'PascalCase' | 'snake_case' | 'kebab-case' | 'CONSTANT_CASE';

Functions

toCamelCase(input: string): string

Converts an input string to camelCase.

  • Throws TypeError if input is not a string.

toPascalCase(input: string): string

Converts an input string to PascalCase (UpperCamelCase).

  • Throws TypeError if input is not a string.

toSnakeCase(input: string): string

Converts an input string to snake_case.

  • Throws TypeError if input is not a string.

toKebabCase(input: string): string

Converts an input string to kebab-case.

  • Throws TypeError if input is not a string.

toConstantCase(input: string): string

Converts an input string to CONSTANT_CASE (SCREAMING_SNAKE_CASE).

  • Throws TypeError if input is not a string.

🆚 How is text-case-converter different?

| Feature | text-case-converter | Other Libraries | | ----------------------- | --------------------- | ---------------- | | Handles acronyms | ✅ Yes | ❌ No | | Handles numbers | ✅ Yes | ❌ No | | Throws on invalid input | ✅ Yes | ❌ No | | Fully typed (TS-first) | ✅ Yes | ⚠️ Often weak | | Tree-shakable | ✅ Yes | ⚠️ Sometimes | | Zero dependencies | ✅ Yes | ❌ No | | 100% test coverage | ✅ Yes | ❌ Rarely | | Modern build tools | ✅ Yes | ⚠️ Inconsistent | | Dual ESM + CJS output | ✅ Yes | ⚠️ Rarely | | Clean, minimal API | ✅ Yes | ⚠️ Often bloated |


🛠️ Contributing

Contributions are welcome! Feel free to open issues or pull requests.


🪪 License

MIT