For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/string/kebabCase.md.

kebabCase es-toolkit

Converts a string to kebab case.

const result = kebabCase(str);

Usage

kebabCase(str)

Use kebabCase when you want to convert a string to kebab case. Kebab case is a naming convention where each word is written in lowercase and connected with dashes (-).

import { kebabCase } from 'es-toolkit/string';

// Convert camel case to kebab case
kebabCase('camelCase');
// Result: 'camel-case'

// Convert a string with whitespace
kebabCase('some whitespace');
// Result: 'some-whitespace'

// Keep strings that are already in kebab case as is
kebabCase('hyphen-text');
// Result: 'hyphen-text'

// Convert strings with uppercase letters
kebabCase('HTTPRequest');
// Result: 'http-request'

This function is useful when creating API endpoints, CSS class names, HTML attributes, etc.

Parameters

strstringrequired

The string to convert to kebab case.

Returns

The string converted to kebab case.

string
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.