Skip to main content

← Back to blog

camelCase, snake_case and kebab-case: A Naming Conventions Guide

“There are only two hard things in computer science: cache invalidation and naming things.” The naming part isn’t just about what you call something — it’s also about the style you write it in. Different languages and ecosystems favour different conventions, and mixing them up makes code look sloppy. Here’s a practical guide.

The main styles

  • camelCase — first word lowercase, each subsequent word capitalized: myVariableName. The default for variables and functions in JavaScript, Java, and many others.
  • PascalCase (a.k.a. UpperCamelCase) — every word capitalized: MyVariableName. Used for classes, types and React components.
  • snake_case — all lowercase, words joined by underscores: my_variable_name. The Python and Ruby standard for variables and functions; also common in database column names.
  • kebab-case — all lowercase, words joined by hyphens: my-variable-name. Used for URLs, CSS classes, and file names. (Not valid for identifiers in most languages because the hyphen reads as a minus sign.)
  • CONSTANT_CASE (SCREAMING_SNAKE_CASE) — all uppercase with underscores: MAX_RETRY_COUNT. Conventionally used for constants and environment variables.

Which language uses what?

Conventions are strong signals of “fitting in” with a codebase:

  • JavaScript / TypeScript — camelCase for variables and functions, PascalCase for classes and types, CONSTANT_CASE for true constants.
  • Python — snake_case for functions and variables, PascalCase for classes, CONSTANT_CASE for module constants (PEP 8).
  • Go — PascalCase for exported names, camelCase for unexported ones.
  • CSS — kebab-case for class names (.main-nav) and custom properties (--brand-color).
  • URLs & files — kebab-case is preferred (/blog/my-post) because it’s readable and URL-safe.

Title Case vs. Sentence case

Two more styles apply to prose rather than code:

  • Title Case capitalizes the first letter of each word — used for headings (“A Naming Conventions Guide”).
  • Sentence case capitalizes only the first letter of the whole line — increasingly popular for UI labels and headings because it reads more naturally.

Converting between styles

You’ll often need to convert a name from one style to another — for example, turning a database column created_at (snake_case) into a JSON field createdAt (camelCase) for an API. Doing this by hand is tedious and error-prone.

Our case converter does it in one click: paste a name or phrase and switch instantly between UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE.

A few tips

  • Be consistent within a project. The specific convention matters less than applying it uniformly.
  • Follow the language’s idiom. Writing snake_case in JavaScript (or camelCase in Python) signals that code doesn’t belong.
  • Use CONSTANT_CASE sparingly — only for genuine constants and environment variables.

Get the style right and your code reads like it belongs. Try the free case converter next time you need to reshape a name.