What Is camelCase and How Does It Format Text?
camelCase (lowerCamelCase) joins words without spaces or punctuation, forcing the first word to lowercase and capitalizing the initial letter of every following word.
camelCase is a naming convention where spaces and punctuation are removed, the first letter of the first word is lowercase, and the first letter of each subsequent word is capitalized (e.g., userProfileImageUrl).
What Regex & Tokenization Rule Does the camelCase Converter Use?
The tokenizer splits input on non-alphanumeric separators (/[^\p{L}\p{N}]+/u) and lowercase-to-uppercase transitions (/(?<=\p{Ll})(?=\p{Lu})/u), then maps word 0 to lowercase and words 1..n to capitalized initial letters.
- Word Boundary Rule: Extract alphanumeric tokens
[\p{L}\p{N}]+and split existing camel/Pascal transitions. - Casing Formula:
words[0].toLowerCase() + words.slice(1).map(w => w[0].toUpperCase() + w.slice(1).toLowerCase()).join(""). - Worked Before / After Example: Input
user profile image URL and authentication token(7 words, 47 characters, 1 line) → OutputuserProfileImageUrlAndAuthenticationToken(1 word, 41 characters, 6 spaces removed).
| Input Format / Rule | Input Example (Before) | Output Result (After) | Characters Changed (count) |
|---|---|---|---|
| Space-Separated Words | user profile image (18 chars, 3 words) |
userProfileImage (16 chars, 1 token) |
2 spaces removed, 2 letters capitalized |
snake_case Identifier (_ delimiter) |
api_response_status_code (24 chars) |
apiResponseStatusCode (21 chars) |
3 underscores removed (-3 chars) |
| CONSTANT_CASE Identifier | MAX_RETRY_COUNT (15 chars) |
maxRetryCount (13 chars) |
2 underscores removed, 11 letters lowercased |
kebab-case Slug (- delimiter) |
background-color-hex (20 chars) |
backgroundColorHex (18 chars) |
2 hyphens removed (-2 chars) |
Where Is camelCase Used in Programming?
camelCase is the standard naming convention for variables, functions, methods, and JSON keys in JavaScript, TypeScript, Swift, Java, and Kotlin.
- JavaScript & TypeScript: Variables, object properties, and function names.
- Swift & Kotlin: Method names and property declarations.
- Java & C#: Local variables and method parameters.
- REST APIs: JSON payload keys.