toSnakeCase
function toSnakeCase(value: string, options?: ToSnakeCaseOptions): string;
The kebab-case rules with underscores in place of hyphens: spaces and hyphens become underscores, an underscore is inserted where a lower-case letter meets an upper-case one, and the result is lowered.
clean removes anything that is not a letter, a digit or an underscore; 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
toSnakeCase("Hello World"); // => "hello_world"
toSnakeCase("userFirstName"); // => "user_first_name"
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.