Skip to main content

Convert snake_case to camelCase

JavaScript version

const snakeToCamel = (str) => str.toLowerCase().replace(/(_\w)/g, (m) => m.toUpperCase().substr(1));

TypeScript version

const snakeToCamel = (str: string): string => str.toLowerCase().replace(/(_\w)/g, (m) => m.toUpperCase().substr(1));

Examples

snakeToCamel('HELLO_world'); // 'helloWorld'

Comments