Skip to content

@technobuddha > library > Programming > Variables

Function: snakeCase()

ts
function snakeCase(input: string): string;

Defined in: snake-case.ts:18

Convert an identifier string to snake case

Parameters

ParameterTypeDescription
inputstringThe identifier string

Returns

string

the identifier in snake case

Example

typescript
snakeCase('hello world'); // 'hello_world'
snakeCase('HelloWorld'); // 'hello_world'
snakeCase('foo_bar-baz'); // 'foo_bar_baz'
snakeCase('FOO BAR'); // 'foo_bar'