You've probably written userName in JavaScript, user_name in Python, and user-name in a URL — all referring to the same concept. The inconsistency isn't arbitrary; each convention exists because it fits a specific ecosystem's syntax rules and readability preferences.
The main conventions
- camelCase — first word lowercase, each following word capitalized, no separators (userName). Standard in JavaScript, Java, and C# for variables and function names.
- PascalCase — like camelCase but the first word is also capitalized (UserName). Used for class and component names in most languages, including React components.
- snake_case — all lowercase, words separated by underscores (user_name). The convention in Python, Ruby, and most SQL database columns.
- kebab-case — all lowercase, words separated by hyphens (user-name). Used in URLs, CSS class names, and HTML attributes, since underscores and camelCase aren't URL- or CSS-friendly.
- SCREAMING_SNAKE_CASE — all uppercase with underscores (USER_NAME). The near-universal convention for constants and environment variables.
Why it's not just style preference
Some of these constraints are technical, not aesthetic. CSS class names and URL slugs can't contain underscores reliably across all tooling, so kebab-case is the safe default there. JavaScript identifiers can't contain hyphens at all — a hyphen would be parsed as subtraction — which is exactly why camelCase took over instead of kebab-case for variables. Environment variables are conventionally uppercase partly because early Unix shells did the same for built-in variables, and the convention stuck as a visual signal for "this is a constant, don't reassign it."
Where mismatches actually cause bugs
The most common place this bites developers is at API boundaries: a backend returning snake_case JSON (common in Python/Ruby APIs) consumed by a JavaScript frontend that expects camelCase. Get the conversion wrong in a serializer or mapping layer and you'll get undefined values instead of an error, which can be a frustrating bug to trace. The fix is usually a consistent transformation layer — convert snake_case to camelCase once, at the API boundary, rather than mixing conventions throughout the codebase.
Quick reference for converting
- Split the input into words (handling existing separators — spaces, underscores, hyphens, or capital-letter boundaries)
- Lowercase (or capitalize) each word according to the target convention
- Join with the target convention's separator (or no separator, for camelCase/PascalCase)
Doing that by hand across a large file of variable names or a CSV of database columns is tedious and error-prone. Paste your text in and convert it to any of the conventions above in one pass — useful for renaming API fields, refactoring variable names, or generating consistent CSS classes from a design spec.