# kebab-case

> Convert a string to kebab-case, i.e. its dash separated form

Latest version **2.0.2** (published 2025-04-11) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 50/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2025-04-11 |
| First published | 2015-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Joakim Carlstein |
| Maintainers | joakimbeng |
| Keywords | kebab-case, kebab, dash, dasherize, dashify, dash-case, train-case, lisp-case |

## Links

- npm: https://www.npmjs.com/package/kebab-case
- Repository: https://github.com/joakimbeng/kebab-case
- Homepage: https://github.com/joakimbeng/kebab-case#readme
- Issues: https://github.com/joakimbeng/kebab-case/issues
- npm.io page: https://npm.io/package/kebab-case

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2025-04-11
- 2.0.1 — 2024-06-28
- 2.0.0 — 2024-06-28
- 1.0.2 — 2022-10-10
- 1.0.1 — 2021-03-05
- 1.0.0 — 2015-12-28

## README

# kebab-case

[![NPM version][npm-image]][npm-url]

> Convert a string to kebab-case, i.e. its dash separated form

The difference between `kebab-case` and e.g. [`dashify`](https://www.npmjs.com/package/dashify) is that this
module doesn't modify the string in any other way than transforming uppercased letters to their lowercased
counterparts prefixed with `-`. Thanks to this there's also a [`reverse`](#kebabcasereversestr) function to
do the opposite, i.e. get back the original value.

This is used in [Unistyle](https://github.com/joakimbeng/unistyle) to transform JavaScript CSS properties
to their CSS counterparts without losing a possible browser prefix, e.g: `WebkitTransform -> -webkit-transform`.

## Installation

Install `kebab-case` using [npm](https://www.npmjs.com/):

```bash
npm install --save kebab-case
```

## Usage

### Module usage

```javascript
import kebabCase from "kebab-case";

kebabCase("WebkitTransform");
// "-webkit-transform"
kebabCase.reverse("-webkit-transform");
// "WebkitTransform"
kebabCase("WebkitTransform", false);
// "webkit-transform"
```

## API

### `kebabCase(str)`

| Name            | Type      | Description                                                 |
| --------------- | --------- | ----------------------------------------------------------- |
| str             | `String`  | The string to convert                                       |
| keepLeadingDash | `Boolean` | Whether to keep the leading dash or not. Default is `true`. |

Returns: `String`, the kebab cased string.

### `kebabCase.reverse(str)`

| Name | Type     | Description                |
| ---- | -------- | -------------------------- |
| str  | `String` | The string to convert back |

Returns: `String`, the "unkebab cased" string.

## License

MIT © [Joakim Carlstein](https://joakim.beng.se/)

[npm-url]: https://npmjs.org/package/kebab-case
[npm-image]: https://badge.fury.io/js/kebab-case.svg

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