CyrefJS
CCyrefJS
فا
Back to documentation
String/Since 1.38.0

camelCase

Converts a string into camelCase by tokenizing its words, lowercasing the first word, and capitalizing the first letter of each remaining word.

camelCase(value):string

Behavior

camelCase first tokenizes the input into words. The first word is converted entirely to lowercase. Every remaining word is converted to lowercase and then its first character is uppercased. The resulting words are joined without separators.

Tokenization

The function delegates word extraction to the internal tokenize utility. The exact boundaries of words therefore depend on tokenize.

Casing rules

The first token is fully lowercased. For every following token, the entire token is first lowercased and then its first character is uppercased.

Empty result

If tokenize returns no words, camelCase returns an empty string.

Parameters

valuestringrequired

The string to convert to camelCase.

Returns

string

The input string converted to camelCase.

Examples

01

Basic usage

Convert a space-separated phrase to camelCase.

TypeScript
import { camelCase } from "@cyref/js";

camelCase("hello world");
// "helloWorld"
02

Multiple words

Each word after the first one starts with an uppercase letter.

TypeScript
camelCase("hello beautiful world");
// "helloBeautifulWorld"
03

Uppercase input

Words are normalized so the first word is lowercase and subsequent words use an uppercase first letter.

TypeScript
camelCase("HELLO WORLD");
// "helloWorld"
04

Single word

A single token is converted to lowercase.

TypeScript
camelCase("HELLO");
// "hello"
05

Empty input

Returns an empty string when tokenization produces no words.

TypeScript
camelCase("");
// ""
06

Mixed case

The output normalizes the casing of every token.

TypeScript
camelCase("hello WoRLD TeST");
// "helloWorldTest"
07

Already camelCase

The string is tokenized and reconstructed using the utility's casing rules.

TypeScript
camelCase("helloWorld");
// "helloWorld"
Built with@cyref/js·Official documentation