# @wordpress/kebab-case

> Convert strings to kebab-case, matching WordPress Core's `_wp_to_kebab_case()`.

Latest version **1.2.0** (published 2026-09-10) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/kebab-case
pnpm add @wordpress/kebab-case
yarn add @wordpress/kebab-case
bun add @wordpress/kebab-case
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-09-10 |
| First published | 2026-08-12 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.10.0 |
| Dependencies | 1 |
| Unpacked size | 49.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11751 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, gutenberg, kebab-case |

## Links

- npm: https://www.npmjs.com/package/@wordpress/kebab-case
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/kebab-case/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/kebab-case

## Dependencies (1)

- [change-case](https://npm.io/package/change-case.md) ^4.1.2

## 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

- 1.2.0 (latest) — 2026-09-10
- 1.1.1-next.v.202609031004.0 (next) — 2026-09-03
- 1.1.1-next.v.202608281122.0 — 2026-08-28
- 1.1.0 — 2026-08-26
- 1.0.0 — 2026-08-12

## README

# Kebab case

Convert strings to kebab-case, matching WordPress Core's [`_wp_to_kebab_case()`](https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/).

This package exists because no off-the-shelf library matches the semantics of WordPress Core's `_wp_to_kebab_case()` function, which WordPress needs to preserve for backwards compatibility.

## Installation

Install the module

```bash
npm install @wordpress/kebab-case --save
```

## Usage

### `kebabCase`

Converts any string to kebab-case.

The conversion is designed to match WordPress Core's [`_wp_to_kebab_case()`](https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/) function (and, transitively, Lodash's [`_.kebabCase()`](https://lodash.com/docs/4.17.15#kebabCase)): the package's test suite covers every test case of the Core function. These semantics differ from other kebab-case implementations in how numbers are handled (`'white23'` becomes `'white-23'`, `'font2xl'` becomes `'font-2-xl'`, yet `'white4th'` stays `'white-4th'`).

```js
import { kebabCase } from '@wordpress/kebab-case';

kebabCase( 'whiteToWhite' ); // 'white-to-white'
kebabCase( 'white2white' ); // 'white-2-white'
kebabCase( 'font2xl' ); // 'font-2-xl'
kebabCase( '#ffffff' ); // 'ffffff'
kebabCase( "i've done" ); // 'ive-done'
```

## API

<!-- START TOKEN(Autogenerated API docs) -->

### kebabCase

Converts any string to kebab case. Backwards compatible with Lodash's `_.kebabCase()`. Backwards compatible with `_wp_to_kebab_case()`.

_Related_

-   <https://lodash.com/docs/4.17.15#kebabCase>
-   <https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/>

_Parameters_

-   _str_ `unknown`: String to convert.

_Returns_

-   Kebab-cased string

<!-- END TOKEN(Autogenerated API docs) -->

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

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