FTJ
← Blog
Text

camelCase vs snake_case vs kebab-case: When to Use Each

Naming conventions keep tripping you up? Here's a practical breakdown of each case style and a free tool to convert between them.

Naming things is hard. Naming them in the right case is harder. I've seen codebases where the same developer used camelCase, snake_case, and kebab-case in the same file — all for variables. Picking a case style and sticking to it saves everyone time.

The Cases That Actually Matter

StyleExampleWhere you'll see it
camelCaseuserNameJavaScript variables, Java methods
PascalCaseUserServiceJS/TS classes, React components, C# types
snake_caseuser_namePython, Rust, file names
kebab-caseuser-nameCSS classes, URL slugs, config keys
SCREAMING_SNAKEMAX_RETRIESConstants, env vars
lowercaseusernameURLs, casual text
UPPERCASEUSERNAMEHeadings, emphasis (rarely in code)
Title CaseUser NameBlog titles, button labels

Why So Many Cases?

Mostly history. C liked lowercase. Java popularized camelCase. Python went with snake_case because it reads more like English. CSS chose kebab-case because hyphens are valid in selectors but camelCase isn't (well, it is now, but nobody uses it).

The conventions stick because consistency within a codebase matters more than which convention you pick.

Case Conversion in Practice

Where you actually need a converter:

  • API field mapping — your backend returns snake_case, your frontend wants camelCase
  • URL slugs — converting a blog title like "My Post Title" to my-post-title
  • Constant extraction — turning defaultTimeout into DEFAULT_TIMEOUT
  • CSS class generation — converting component names to kebab-case selectors

I've written these conversions as one-liners too many times. The text case converter on this site handles all the common styles — paste your text, pick the target case, copy the result.

## Text Case Types Explained

Different case styles serve different purposes:

  • UPPERCASE: All letters capitalized. Used for emphasis, warnings, and acronyms.
  • lowercase: All letters lowercase. Used in code identifiers (Python, CSS), URLs, and informal text.
  • Title Case: First letter of each word capitalized. Used for book titles, article headlines, and song titles.
  • Sentence case: First letter of each sentence capitalized. Standard for prose.
  • camelCase: First word lowercase, subsequent words capitalized. Used in JavaScript, Java, and C# for variables and functions.
  • PascalCase: Every word capitalized. Used for class names in many languages.
  • snake_case: Words separated by underscores, typically lowercase. Used in Python, Ruby, and database column names.
  • kebab-case: Words separated by hyphens. Used in URLs, CSS class names, and file names.
  • CONST_CASE: All uppercase with underscores. Used for constants in many languages.

Case Conversion Pitfalls

  1. Locale sensitivity: In Turkish, the lowercase of I is ı (dotless i), not i. Most programming languages handle this incorrectly unless you specify a locale.
  2. Unicode: Converting case for non-ASCII characters (é, ñ, ß) requires Unicode-aware functions. JavaScript toUpperCase() handles most cases, but some edge cases fail.
  3. Existing case: Converting XMLParser to snake_case should produce xml_parser, not x_m_l_parser. Smart case converters detect existing capitalization boundaries.

Try These Tools

More Articles