camelCase vs snake_case vs kebab-case: A Naming Convention Guide for Developers
Ask five developers which naming convention is "correct" and you will likely get five different answers — because the honest answer is that it depends entirely on the language, platform, or context you are working in. What matters more than picking a personal favorite is knowing which convention each situation expects.
The Four Common Styles
- camelCase —
firstName,totalPrice. First word lowercase, each following word capitalized, no separators. - PascalCase —
UserProfile,OrderSummary. Same as camelCase but the first word is also capitalized. - snake_case —
first_name,total_price. All lowercase, words separated by underscores. - kebab-case —
first-name,total-price. All lowercase, words separated by hyphens.
Where Each One Is Expected
camelCase is the default for variables and functions in JavaScript, TypeScript, and Java. PascalCase is used for class and component names in those same languages — React components, for example, must be PascalCase or React will not treat them as components.
snake_case is the standard for variables and function names in Python and Ruby, and it is also the near-universal convention for database column and table names, even in codebases that use camelCase everywhere else.
kebab-case is not used inside most programming languages at all — hyphens are treated as subtraction operators — but it is the expected style for URL slugs, HTML attributes, and CSS class names, because it is the most readable format in contexts where case sensitivity is often unreliable.
Why Mixing Conventions Causes Real Problems
Inconsistent casing in one codebase is more than a style nitpick. It slows down code review, breaks auto-complete expectations, and in some contexts causes actual bugs — a JSON API that returns snake_case keys but a frontend that expects camelCase will silently fail to read fields unless a conversion layer is added.
Conclusion
There is no universally "correct" naming convention — there is only the convention a given language, platform, or context expects. Learn the four styles above, follow whatever the surrounding codebase already uses, and convert between them with a tool rather than manually retyping when you need to switch contexts.