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

variable-name-conversion

v1.7.0

Published

To easily convert a variable name to camelCase, kebab-case, etc.

Readme

Variable Name Conversion

npm GitHub License: MIT

To easily convert a variable name to camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, etc.

Supports strong typing hints of TypeScript for static strings.

Installation

# npm
npm install variable-name-conversion

# yarn
yarn add variable-name-conversion

# pnpm
pnpm add variable-name-conversion

Usage

Value with Type

import VariableName from "variable-name-conversion";

const camel = new VariableName("hello_world").camel; //=> "helloWorld"
const kebab = new VariableName("fooBarBaz").kebab; //=> "foo-bar-baz"

Type only

Useful when you want to use static string type conversion without introduce runtime.

import type VariableName from "variable-name-conversion";

type Camel = VariableName<"hello_world">["camel"]; //=> "helloWorld"
type Kebab = VariableName<"fooBarBaz">["kebab"]; //=> "foo-bar-baz"

Cases

Case | Example | Notes --- | --- | --- camel | camelCase pascal | PascalCase kebab | kebab-case snake | snake_case const | CONSTANT_CASE train | Train-Case cobol | COBOL-CASE pascalSnake | Pascal_Snake_Case camelSnake | camel_Snake_Case dot | dot.case path | path/case pathAlt | path\alt\case lower | lowercase | With no separators. upper | UPPERCASE | With no separators. words | word case | Separated by spaces, all in lowercase. sentence | Sentence case | Separated by spaces, with only the first letter of the sentence capitalized. title | Title Case | Separated by spaces, with all first letters of words capitalized. cssVar | --css-custom-property-name-form | kebab-case with two dashes as the prefix. cssProp | css-property-name-form-webkit-css-property-name-form | Just like kebab-case, but if the first word is in "webkit", "moz", "ms", "o", it will use one dash as the prefix.

Options

keepCase

Should it maintain case sensitivity when converting to kebab-case, snake_case, etc.?

Default: false

Example:

const snakeI = new VariableName("XMLHttpRequest").snake; //=> "xml_http_request"
const snakeS = new VariableName("XMLHttpRequest", true).snake; //=> "XML_Http_Request"

const camelI = new VariableName("XMLHttpRequest").camel; //=> "xmlHttpRequest"
const camelS = new VariableName("XMLHttpRequest", true).camel; //=> "XMLHttpRequest"

type SnakeI = VariableName<"XMLHttpRequest">["snake"]; //=> "xml_http_request"
type SnakeS = VariableName<"XMLHttpRequest", true>["snake"]; //=> "XML_Http_Request"

type CamelI = VariableName<"XMLHttpRequest">["camel"]; //=> "xmlHttpRequest"
type CamelS = VariableName<"XMLHttpRequest", true>["camel"]; //=> "XMLHttpRequest"

With numbers

Special case when handling value mixed with numbers.

Example:

const snake1 = new VariableName("resolve404Error").snake; //=> "resolve_404_error"
const snake2 = new VariableName("watch3d1080pVideo").snake; //=> "watch_3d_1080p_video"

type Snake1 = VariableName<"resolve404Error">["snake"]; //=> "resolve_404_error"
type Snake2 = VariableName<"watch3d1080pVideo">["snake"]; //=> "watch_3d_1080p_video"

License

variable-name-conversion is available under the MIT License. See the LICENSE file for more info.