For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/string/camelCase.md.

camelCase es-toolkit

Converts a string to camel case.

const result = camelCase(str);

Usage

camelCase(str)

Use camelCase when you want to convert a string to camel case. Camel case is a naming convention where the first word is lowercase and the first letter of each subsequent word is capitalized.

import { camelCase } from 'es-toolkit/string';

// Convert various string formats to camel case
camelCase('hello world'); // returns 'helloWorld'
camelCase('some-hyphen-text'); // returns 'someHyphenText'
camelCase('CONSTANT_CASE'); // returns 'constantCase'
camelCase('PascalCase'); // returns 'pascalCase'
camelCase('mixed   SpAcE'); // returns 'mixedSpAcE'

It converts strings with special characters, spaces, hyphens, and other separators into a format suitable for JavaScript variable names or object property names.

import { camelCase } from 'es-toolkit/string';

// Convert keys from API responses
const apiKey = 'user_first_name';
const jsKey = camelCase(apiKey); // 'userFirstName'

// Convert HTML attributes to JavaScript properties
const cssProperty = 'background-color';
const jsProperty = camelCase(cssProperty); // 'backgroundColor'

It also preserves Unicode characters.

import { camelCase } from 'es-toolkit/string';

camelCase('keep unicode 😅'); // returns 'keepUnicode😅'
camelCase('한글-테스트'); // returns '한글테스트'

Parameters

strstringrequired

The string to convert to camel case.

Returns

Returns a new string converted to camel case.

string
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.