apps-script-utils 2.1.1 Help

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

value

string

The string to convert. It must not be empty.

options (optional) = {}

ToKebabCaseOptions

clean removes the remaining punctuation; trim trims and collapses whitespace.

Returns

string — the converted string.

Throws

Exception

Condition

EmptyStringException

the value is not a string, or is empty.

Examples

Converting

toKebabCase("Hello World"); // => "hello-world" toKebabCase("userFirstName"); // => "user-first-name"

See also

Source

src/lang/string/toKebabCase.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.