Skip to content

Function: decamelize()

ts
function decamelize(text: string, options?: {
  preserveConsecutiveUppercase?: boolean;
  separator?: string;
}): string;

Convert camelCase or PascalCase text to separated lowercase text.

Parameters

ParameterTypeDescription
textstringText to convert.
options{ preserveConsecutiveUppercase?: boolean; separator?: string; }Conversion options.
options.preserveConsecutiveUppercase?booleanWhether consecutive uppercase runs keep their casing. Defaults to false.
options.separator?stringSeparator inserted between words. Defaults to _.

Returns

string

Converted text.

Remarks

When preserveConsecutiveUppercase is enabled, acronym runs such as URL keep their original casing unless the last uppercase letter starts the following lowercase word.