camelCase, snake_case, kebab-case: Case Converter Guide
Last updated: · 3 min read
Joining words into a name can be written in several conventions: userName in JavaScript, user_name in Python and user-name in CSS class names. Using the wrong convention rarely breaks a compiler, but it makes code harder to read and can violate a team's style rules. This guide describes the most common case formats and how words are split before they are joined. It also explains why Turkish text needs its own rules, because the dotted and dotless i are different letters in Turkish. The outputs in the example come from the Case Converter tool.
Formula
1. Split the text at every character that is not a letter or digit: w1, w2, …, wn 2. Convert each word to lower case (using the locale rules) 3. camelCase = w1 + Capitalise(w2) + Capitalise(w3) + … 4. PascalCase = Capitalise(w1) + Capitalise(w2) + … 5. snake_case = w1 "_" w2 "_" …; kebab-case = w1 "-" w2 …; dot.case = w1 "." w2 … 6. CONSTANT_CASE = every word in upper case, joined with "_" 7. Title Case: first letter of every word capitalised; Sentence case: only the first letter of the first word capitalised
Once the words are split, only the letter case and the separator change. Case conversion follows the Unicode case mapping rules; in Turkish locale (tr) the capital of I is ı and the capital of İ is i. The tool therefore uses toLocaleLowerCase and toLocaleUpperCase with the Turkish locale when the interface language is Turkish. The names of the formats are community conventions, not a single standard.
What the inputs mean
- Text
- The word or phrase to convert, for example user profile page. Words may be separated by spaces, hyphens or underscores; punctuation marks also act as separators.
Worked example: Converting a three-word phrase
- Input: user profile page. Three words are found: “user”, “profile” and “page”.
- camelCase keeps the first word in lower case and capitalises the rest: userProfilePage.
- snake_case lowercases every word and joins them with underscores: user_profile_page.
- CONSTANT_CASE uppercases every word: USER_PROFILE_PAGE.
- Title Case gives User Profile Page; Sentence case gives User profile page, because only the first letter is capitalised.
Result: Tool output: camelCase: userProfilePage, PascalCase: UserProfilePage, snake_case: user_profile_page, kebab-case: user-profile-page, CONSTANT_CASE: USER_PROFILE_PAGE, Title Case: User Profile Page.
🔠 Case Converter (camelCase…)
Free, no sign-up; your data stays in your browser.
Open the calculator →How to read the result
Choose the convention your language and team already use: JavaScript and Java variables are usually camelCase, Python variables and functions use snake_case, classes use PascalCase, and CSS class names and URL slugs usually use kebab-case. Constants are often written in CONSTANT_CASE. Check your team's style guide before renaming anything in an existing codebase, because changing names can break other code that depends on them.
Common mistakes
- Splitting words incorrectly. A name such as XMLHttpRequest contains several word boundaries, and a simple split may produce the wrong result.
- Using camelCase for constants. Constants read more clearly in CONSTANT_CASE, which makes them stand out in code.
- Using underscores in URLs. Search engines treat hyphens as word separators, while underscores are not read that way in the same manner.
- Mixing two conventions in one file. If userName and user_name appear side by side, readers cannot tell which rule applies.
- Ignoring locale rules. In Turkish, the capital of i is İ and the capital of ı is I; a generic conversion can produce wrong letters.
Frequently asked questions
What is the difference between camelCase and PascalCase?
camelCase starts with a lower-case letter (userName), while PascalCase starts with an upper-case letter (UserName). Class names are often written in PascalCase.
Which format should I use?
Follow the convention of your language and team: camelCase for JavaScript variables, snake_case for Python, kebab-case for CSS classes and URL slugs.
Why are Title Case and Sentence case different?
Title Case capitalises every word, which suits headings. Sentence case capitalises only the first word, which suits ordinary sentences and labels.
Is my text sent to a server?
The conversion happens in your browser on the page. Still, avoid entering secret names or keys in any online tool.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.