The naming styles, and what each one is actually for
Five styles cover almost every case you'll run into:
- camelCase joins words without separators and capitalizes each word after the first, as in firstName. It is common for JavaScript and Java variables and methods, but project rules still take precedence.
- PascalCase capitalizes every word, as in FirstName. Many ecosystems use it for classes, components or types.
- snake_case joins lowercase words with underscores, as in first_name. Python commonly uses it for functions and variables; database conventions vary by team and platform.
- kebab-case joins lowercase words with hyphens, as in first-name. It is common in URL slugs and CSS classes, although URL safety also depends on the complete character set and encoding.
- CONSTANT_CASE uses uppercase words separated by underscores, as in FIRST_NAME. It often marks constants or environment variables, but capitalization does not enforce immutability.
Why the convention matters more than the choice
None of these styles is technically superior; a JavaScript variable named first_name instead of firstName still works exactly the same. What breaks is consistency: mixing styles within one codebase forces every reader to context-switch for no reason, and some tools genuinely can't cross styles safely (a CSS class must be kebab-case-safe, a URL slug can't contain characters that need encoding, and a case-sensitive filesystem will treat MyFile and myfile as two different files while a case-insensitive one won't). The style itself is a convention; picking one and applying it consistently is what actually matters.
Where each style tends to show up
- Variables and functions: camelCase (JavaScript, Java) or snake_case (Python, Ruby); pick whichever your language's own standard library and style guide already use, not a personal preference.
- Classes and types: often PascalCase, though language and framework conventions differ.
- URLs and slugs: commonly kebab-case because hyphens visibly separate words; search behavior should not be reduced to a universal ranking rule.
- CSS classes: kebab-case is the long-standing convention (
.nav-link), though some component-based frameworks use camelCase for CSS-in-JS. - Constants and environment variables: often CONSTANT_CASE by convention, without any guarantee that the value cannot change.
Questions that come up in real projects
JSON imposes no casing rule on member names. Match the API contract exactly; changing case creates a different key.
kebab-case, dash-case and spinal-case usually name the same hyphen-separated style, though terminology is not formally standardized everywhere.
Hyphens are a clear word separator in URLs and are widely recommended for readable slugs. The practical reason is clarity and convention, not a claim that every search engine interprets underscores identically.
Convert between cases
Orisod’s Case Converter switches text among common letter and identifier styles in your browser. Review acronyms, punctuation and non-Latin text after conversion.
Convert text case →Use the convention expected by the language, framework or external API, then apply it consistently. Conversion tools cannot always infer acronyms, Unicode word boundaries or the intended segmentation of an existing identifier.