Guides / Naming Conventions

camelCase vs snake_case vs kebab-case

4 min read · Developer fundamentals

The five main naming styles

StyleExampleCharacter
camelCasegetUserNameStarts lowercase, capitals for each new word
PascalCaseGetUserNameLike camelCase but first letter is also capital
snake_caseget_user_nameAll lowercase, words separated by underscores
kebab-caseget-user-nameAll lowercase, words separated by hyphens
SCREAMING_SNAKE_CASEGET_USER_NAMEAll uppercase with underscores

Where each style is used

camelCase

  • JavaScript / TypeScript variables and functions: const userName = ...
  • JSON keys: {"firstName": "Ana"}
  • Java methods and fields

PascalCase

  • JavaScript / TypeScript classes and React components: UserProfile
  • TypeScript interfaces and types: interface UserData
  • C# methods and properties

snake_case

  • Python variables and functions: def get_user_name():
  • Database column names: created_at, user_id
  • Ruby and PHP variables

kebab-case

  • CSS class names: .nav-bar, .btn-primary
  • URL slugs: /blog/how-to-format-json
  • HTML attributes and custom data attributes: data-user-id
  • npm package names: react-router-dom

SCREAMING_SNAKE_CASE

  • Constants and environment variables: DATABASE_URL, MAX_RETRIES
  • Python and C constants

Quick reference by language

LanguageVariables/FunctionsClassesConstants
JavaScript / TScamelCasePascalCaseUPPER_SNAKE
Pythonsnake_casePascalCaseUPPER_SNAKE
GocamelCasePascalCasePascalCase
CSSkebab-casekebab-case--kebab-case
SQLsnake_casesnake_caseUPPERCASE

Naming in REST APIs

REST APIs typically use snake_case or camelCase for JSON keys — there is no universal standard, but you should be consistent across your entire API.

// snake_case (common in Python/Ruby APIs)
{ "created_at": "2025-01-01", "user_name": "Ana" }

// camelCase (common in JavaScript/Node.js APIs)
{ "createdAt": "2025-01-01", "userName": "Ana" }

URL paths and query parameters should always use kebab-case:/api/user-profiles?sort-by=name

Why consistency matters more than which style

Mixing styles in the same codebase is harder to read than consistently using any single style. A codebase with user_name in one file and userName in another creates cognitive friction — developers have to remember which file uses which convention.

Pick the convention that matches your language's standard library and stick to it. Linters (ESLint for JavaScript, pylint/black for Python) can enforce naming conventions automatically.

Convert between naming styles instantly

Paste any text and convert it to camelCase, snake_case, kebab-case, PascalCase, or UPPER_SNAKE_CASE.

Case Converter →