Every programming language and framework has opinions about text casing. Use the wrong convention and your code either breaks or fails code review. The rules are not arbitrary -- they encode information about what a name represents.
The major cases
camelCase: First word lowercase, subsequent words capitalized. No separators. Used for variables, function names, and object properties in JavaScript, Java, and C#.
let userName = 'Alice';
function calculateTotal() {}
PascalCase (UpperCamelCase): Every word capitalized. Used for class names, components, and types in most languages.
class UserAccount {}
function DropdownMenu() {} // React component
type HttpResponse = {} // TypeScript type
snake_case: All lowercase, words separated by underscores. Used for variables and functions in Python, Ruby, and Rust.
user_name = 'Alice'
def calculate_total():
pass
SCREAMING_SNAKE_CASE: All uppercase, words separated by underscores. Used for constants in virtually every language.
const MAX_RETRIES = 3;
const API_BASE_URL = 'https://api.example.com';
kebab-case: All lowercase, words separated by hyphens. Used for CSS class names, URL slugs, HTML attributes, and file names.
.user-profile-card { }
<my-custom-element data-user-id="123">
TRAIN-CASE (COBOL-CASE): All uppercase, words separated by hyphens. Used for HTTP headers.
Content-Type: application/json
X-Request-ID: abc123
dot.case: Words separated by dots. Used for Java package names and some configuration keys.
com.example.myapp
database.connection.pool_size
Why the conventions exist
Casing conventions are not just style preferences. They carry semantic meaning.
In Python, MAX_RETRIES being in SCREAMING_SNAKE_CASE tells every reader it is a constant without looking at how it is defined. _private_method with a leading underscore signals it is intended for internal use. __dunder__ methods are Python special methods.
In JavaScript, UserService in PascalCase tells you it is a class or constructor. If you call it without new, it is a bug. userService in camelCase is an instance or a plain function.
In React, Button is a component (must be PascalCase for JSX to recognize it as a component rather than an HTML element). button is a native HTML element. This is not a convention -- it is a parser requirement.
Conversion is harder than it looks
Converting between cases requires correctly identifying word boundaries. The challenges:
Acronyms. Is XMLParser one word or two? In camelCase, it could be xmlParser or xMLParser. Common convention is to treat acronyms as single words: XmlParser in PascalCase, xmlParser in camelCase. But not everyone agrees, which is why XMLHttpRequest exists in the JavaScript standard library.
Numbers. user2fa -- is that user-2-fa or user-2fa? Context-dependent, and automated converters often get it wrong.
Existing separators. Converting user_name to camelCase is straightforward. Converting user__name (double underscore) is ambiguous. Is the extra underscore intentional or a typo?
Unicode. Converting über to UPPERCASE gives ÜBER in most locales. But Turkish has special rules where i uppercases to I (with a dot) rather than I. The toUpperCase function in JavaScript uses locale-independent rules, which may not match your expectations.
The practical workflow
I find myself converting between cases constantly. A database column named created_at becomes createdAt in JavaScript, created-at in a CSS class, and CREATED_AT in a constant. Doing this by hand is error-prone, especially for long multi-word names.
I built a text case converter at zovo.one/free-tools/text-case-converter that handles all major conventions: camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, dot.case, Title Case, and sentence case. Paste any text and it detects the current case, splits word boundaries correctly (including acronym handling), and converts to all other formats simultaneously.
It is a tiny tool that removes a tiny friction point from every single coding session.
I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.
Top comments (0)