How an identifier is split, then spelled again
camelCase, PascalCase, snake_case, kebab-case, and CONSTANT_CASE are different spellings of the same word list. A converter is only correct if it finds the same boundaries a reader would: a lowercase or digit before an uppercase letter, plus underscores, hyphens, and spaces.
JSON keys often follow one convention and CSS classes another. Compare the object in the JSON formatter and the selectors in the CSS formatter when a payload and a stylesheet disagree on the same name.
Word boundaries and the five compound styles
Where a compound name is cut into words
- A lowercase letter or digit followed by an uppercase letter is a camel boundary (myVar, version2Name).
- Runs of underscores or hyphens become a single gap (hello_world-example).
- Spaces and line breaks are gaps too; each line is converted on its own.
- A run of capitals with no lowercase before the next capital stays one token (HTTPResponse).
How camel, Pascal, snake, kebab, and constant rejoin words
- camelCase lowercases the first word and capitalizes the rest (userProfileId).
- PascalCase capitalizes every word and concatenates them (UserProfileId).
- snake_case lowercases every word and joins with underscores (user_profile_id).
- kebab-case uses hyphens; CONSTANT_CASE is snake_case written in capitals (USER_PROFILE_ID).
Why UPPER, lower, and sentence case do not retokenize
- Those three styles change letters in the original string and leave _, -, and spaces where they were.
- hello_world in UPPERCASE is HELLO_WORLD, not a new word list.
- Sentence case lowercases the whole text and capitalizes only the first character.
- Title Case is the exception: it splits words, then capitalizes each one and joins with spaces.
Why acronyms and digits do not always match a human split
- HTTPResponse has no lowercase-before-uppercase cut, so it becomes one word, httpresponse, in camelCase.
- XMLHttpRequest does split, because the lowercase p and l sit before the next capital: xmlHttpRequest.
- Digits stick to the word before them unless an uppercase letter follows (userID2 → user, ID2).
- If a team keeps HTTP as its own word, insert a separator before converting.
Where the spelling actually matters
API fields crossing languages
Python and PostgreSQL often use snake_case; TypeScript objects usually use camelCase. Convert the key list at the boundary.
CSS classes and env keys
kebab-case is normal in stylesheets; CONSTANT_CASE is normal in environment variables. The words stay the same.