Skip to content

kebabCase() function

Converts str to kebab case.

Word boundaries are detected from spaces, punctuation, digits, case changes, and acronyms.

Signature:

typescript
declare function kebabCase(str: string): string;

Example

ts
kebabCase("foo bar"); // "foo-bar"
kebabCase("fooBar"); // "foo-bar"
kebabCase("foo_bar"); // "foo-bar"
kebabCase("XMLHttpRequest"); // "xml-http-request"

Open Source Code

Released under the Apache-2.0 License.