GitHub 6219★

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'
Follow me on and to get more useful contents.