# change-case

> Transform a string between `camelCase`, `PascalCase`, `Capital Case`, `snake_case`, `kebab-case`, `CONSTANT_CASE` and others

Latest version **5.4.4** (published 2024-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install change-case
pnpm add change-case
yarn add change-case
bun add change-case
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.4.4 |
| Published | 2024-04-03 |
| First published | 2013-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2406 |
| Author | Blake Embrey |
| Maintainers | blakeembrey |
| Keywords | change, case, convert, transform, camel-case, pascal-case, param-case, kebab-case, header-case |

## Links

- npm: https://www.npmjs.com/package/change-case
- Repository: https://github.com/blakeembrey/change-case
- Homepage: https://github.com/blakeembrey/change-case/tree/master/packages/change-case#readme
- Issues: https://github.com/blakeembrey/change-case/issues
- npm.io page: https://npm.io/package/change-case

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 5.4.4 (latest) — 2024-04-03
- 5.4.3 — 2024-02-14
- 5.4.2 — 2024-01-14
- 5.4.1 — 2024-01-10
- 5.4.0 — 2024-01-08
- 5.3.0 — 2023-12-06
- 5.2.0 — 2023-11-17
- 5.1.2 — 2023-10-20
- 5.1.1 — 2023-10-20
- 5.1.0 — 2023-10-18
- 5.0.2 — 2023-10-03
- 5.0.1 — 2023-09-30
- 5.0.0 — 2023-09-30
- 4.1.2 — 2020-12-02
- 4.1.1 — 2019-12-19
- … 30 more at https://npm.io/package/change-case/versions

## README

# Change Case

> Transform a string between `camelCase`, `PascalCase`, `Capital Case`, `snake_case`, `kebab-case`, `CONSTANT_CASE` and others.

## Installation

```
npm install change-case --save
```

## Usage

```js
import * as changeCase from "change-case";

changeCase.camelCase("TEST_VALUE"); //=> "testValue"
```

Included case functions:

| Method            | Result      |
| ----------------- | ----------- |
| `camelCase`       | `twoWords`  |
| `capitalCase`     | `Two Words` |
| `constantCase`    | `TWO_WORDS` |
| `dotCase`         | `two.words` |
| `kebabCase`       | `two-words` |
| `noCase`          | `two words` |
| `pascalCase`      | `TwoWords`  |
| `pascalSnakeCase` | `Two_Words` |
| `pathCase`        | `two/words` |
| `sentenceCase`    | `Two words` |
| `snakeCase`       | `two_words` |
| `trainCase`       | `Two-Words` |

All methods accept an `options` object as the second argument:

- `delimiter?: string` The character to use between words. Default depends on method, e.g. `_` in snake case.
- `locale?: string[] | string | false` Lower/upper according to specified locale, defaults to host environment. Set to `false` to disable.
- `split?: (value: string) => string[]` A function to define how the input is split into words. Defaults to `split`.
- `prefixCharacters?: string` Retain at the beginning of the string. Defaults to `""`. Example: use `"_"` to keep the underscores in `__typename`.
- `suffixCharacters?: string` Retain at the end of the string. Defaults to `""`. Example: use `"_"` to keep the underscore in `type_`.

By default, `pascalCase` and `snakeCase` separate ambiguous characters with `_`. For example, `V1.2` would become `V1_2` instead of `V12`. If you prefer them merged you can set `mergeAmbiguousCharacters` to `true`.

### Split

**Change case** exports a `split` utility which can be used to build other case functions. It accepts a string and returns each "word" as an array. For example:

```js
split("fooBar")
  .map((x) => x.toLowerCase())
  .join("_"); //=> "foo_bar"
```

## Change Case Keys

```js
import * as changeKeys from "change-case/keys";

changeKeys.camelCase({ TEST_KEY: true }); //=> { testKey: true }
```

**Change case keys** wraps around the core methods to transform object keys to any case.

### API

- **input: any** Any JavaScript value.
- **depth: number** Specify the depth to transfer for case transformation. Defaults to `1`.
- **options: object** Same as base case library.

## TypeScript and ESM

This package is a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) and ships with TypeScript definitions. It cannot be `require`'d or used with CommonJS module resolution in TypeScript.

## License

MIT

---
_Source: https://npm.io/package/change-case · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
