EthicalFusion
Data & Developers

camelCase vs snake_case: A Guide to Naming Conventions in Code

camelCase, snake_case, kebab-case, PascalCase and CONSTANT_CASE — what each is, where it's used, and a free converter.

By the EthicalFusion team Published Updated 2 min read

Spaces aren't allowed in identifiers, so programmers invented a dozen ways to glue words together. Using the wrong one isn't a bug, but it marks code as out of place — every language and ecosystem has its conventions.

The main cases

camelCase — first word lower, rest capitalized (userName). PascalCase — every word capitalized (UserName). snake_case — lowercase with underscores (user_name). kebab-case — lowercase with hyphens (user-name). CONSTANT_CASE — uppercase with underscores (USER_NAME). Convert a phrase into all of them at once with the code case converter.

Who uses what

JavaScript/Java: camelCase for variables, PascalCase for classes. Python/Ruby: snake_case for variables and functions, PascalCase for classes. CSS and URLs: kebab-case. Constants: CONSTANT_CASE almost everywhere. Databases: usually snake_case columns.

Why consistency matters

Mixed casing makes code harder to scan and breaks autocomplete habits. The rule isn't "this case is best" — it's "match the surrounding code and the language's convention". A Python file full of camelCase reads as foreign even though it runs fine.

Bonus: URL slugs

For web addresses and filenames, kebab-case wins — it's readable and search-engines treat hyphens as word separators. Turn any title into a clean URL slug with the slug generator.

Let tools do the conversion

Renaming a variable across cases by hand is error-prone. Paste the phrase into the code case converter and copy the exact form you need — camelCase for the variable, CONSTANT_CASE for the config key, kebab-case for the CSS class.

  • #programming
  • #naming conventions
  • #developers
  • #code style

Tools used in this guide

Free, no sign-up, and they run in your browser.

About EthicalFusion

EthicalFusion offers 321 free online tools for money, documents, images, writing and code. This guide was written by the team that builds them. Calculators give estimates, so confirm important figures with your bank, CA or doctor.

About us Suggest a correction

Keep reading

All articles