toKebabCase
function toKebabCase(value: string, options: ToKebabCaseOptions = {}): string;
Spaces and underscores become hyphens, a hyphen is inserted where a lower-case letter meets an upper-case one, and the result is lowered. That second rule is what splits "userFirstName" into three words.
clean removes anything that is not a letter, a digit or a hyphen; trim collapses the surrounding whitespace first.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The string to convert. It must not be empty. |
|
|
|
Returns
string — the converted string.
Throws
Exception | Condition |
|---|---|
| the value is not a string, or is empty. |
Examples
Converting
toKebabCase("Hello World"); // => "hello-world"
toKebabCase("userFirstName"); // => "user-first-name"
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.