1.38.0camelCase
Converts a string into camelCase by tokenizing its words, lowercasing the first word, and capitalizing the first letter of each remaining word.
camelCase(value):stringBehavior
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
valuestringrequiredThe string to convert to camelCase.
Returns
stringThe input string converted to camelCase.
Examples
Basic usage
Convert a space-separated phrase to camelCase.
import { camelCase } from "@cyref/js";
camelCase("hello world");
// "helloWorld"Multiple words
Each word after the first one starts with an uppercase letter.
camelCase("hello beautiful world");
// "helloBeautifulWorld"Uppercase input
Words are normalized so the first word is lowercase and subsequent words use an uppercase first letter.
camelCase("HELLO WORLD");
// "helloWorld"Single word
A single token is converted to lowercase.
camelCase("HELLO");
// "hello"Empty input
Returns an empty string when tokenization produces no words.
camelCase("");
// ""Mixed case
The output normalizes the casing of every token.
camelCase("hello WoRLD TeST");
// "helloWorldTest"Already camelCase
The string is tokenized and reconstructed using the utility's casing rules.
camelCase("helloWorld");
// "helloWorld"