Convert a string to kebab-case, i.e. its dash separated form
JavaScript
26
12 commits
updated Nov 21, 2025
Convert a string to kebab-case, i.e. its dash separated form
The difference between kebab-case and e.g. 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 function to
do the opposite, i.e. get back the original value.
This is used in Unistyle to transform JavaScript CSS properties
to their CSS counterparts without losing a possible browser prefix, e.g: WebkitTransform -> -webkit-transform.
Install kebab-case using npm:
npm install --save kebab-case
import kebabCase from "kebab-case";
kebabCase("WebkitTransform");
// "-webkit-transform"
kebabCase.reverse("-webkit-transform");
// "WebkitTransform"
kebabCase("WebkitTransform", false);
// "webkit-transform"
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.
MIT © Joakim Carlstein
Overall
Maintained
Code review
npm
Latest release
Releases this year
94 followers · starred Jan 2023
Convert a string to kebab-case, i.e. its dash separated form
JavaScript
26
12 commits
updated Nov 21, 2025
Convert a string to kebab-case, i.e. its dash separated form
The difference between kebab-case and e.g. 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 function to
do the opposite, i.e. get back the original value.
This is used in Unistyle to transform JavaScript CSS properties
to their CSS counterparts without losing a possible browser prefix, e.g: WebkitTransform -> -webkit-transform.
Install kebab-case using npm:
npm install --save kebab-case
import kebabCase from "kebab-case";
kebabCase("WebkitTransform");
// "-webkit-transform"
kebabCase.reverse("-webkit-transform");
// "WebkitTransform"
kebabCase("WebkitTransform", false);
// "webkit-transform"
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.
MIT © Joakim Carlstein
Overall
Maintained
Code review
npm
Latest release
Releases this year
94 followers · starred Jan 2023