camelCase, snake_case, kebab-case — A Developer's Guide to Case Conventions

Different programming languages and contexts use different naming conventions. Learn when to use camelCase, snake_case, PascalCase, and kebab-case.

Why naming conventions matter

Code is read far more often than it’s written. Consistent naming conventions make code scannable — experienced developers can immediately identify what something is from its name format. When conventions are inconsistent or wrong for the context, code becomes harder to read and maintain.

Different languages, frameworks, and contexts have different conventions. JavaScript uses camelCase for variables. Python prefers snake_case. URLs use kebab-case. Database columns often use snake_case. Class names use PascalCase. Knowing which to use when — and why — prevents the subtle bugs and style inconsistencies that make code harder to work with.

Convert text between any case format instantly with Case Converter.

The main case formats

camelCase — The first word is lowercase; subsequent words start with uppercase. myVariableName, getUserById, isAuthenticated.

PascalCase (also called UpperCamelCase) — Every word starts with uppercase. MyClassName, UserProfileComponent, HttpRequestHandler.

snake_case — All lowercase, words separated by underscores. user_profile, max_retry_count, created_at.

SCREAMING_SNAKE_CASE — All uppercase with underscores. MAX_CONNECTIONS, API_BASE_URL, DEFAULT_TIMEOUT.

kebab-case — All lowercase, words separated by hyphens. user-profile, api-endpoint, my-component.

dot.case — Words separated by dots. user.profile.id. Used in config files, Java packages, and file paths.

Convention by context

JavaScript and TypeScript

  • Variables and functions: camelCase (getUserData, isLoggedIn, maxRetries)
  • Classes and interfaces: PascalCase (UserService, ApiResponse)
  • Constants: SCREAMING_SNAKE_CASE for module-level constants (MAX_FILE_SIZE, BASE_URL)
  • React components: PascalCase (UserProfile, NavigationBar)
  • CSS class names in JS: varies — often kebab-case or camelCase depending on the CSS-in-JS solution

Python

  • Variables and functions: snake_case (user_data, get_user_by_id)
  • Classes: PascalCase (UserManager, HttpClient)
  • Constants: SCREAMING_SNAKE_CASE (MAX_CONNECTIONS, DEFAULT_TIMEOUT)
  • Module names: snake_case (user_service.py, api_client.py)

Databases

  • Table names: snake_case (user_profiles, order_items) or PascalCase depending on the database system
  • Column names: snake_case strongly preferred (first_name, created_at, is_active)
  • Avoid camelCase in SQL — SQL is case-insensitive and most tools normalize column names, making camelCase columns inconsistent

URLs and file paths

  • URLs: kebab-case (/user-profile/, /api/v2/get-orders)
  • HTML files: kebab-case (user-profile.html, contact-form.css)
  • JavaScript modules: kebab-case for files (user-service.js, api-client.ts)

CSS

  • Class names: kebab-case (.nav-link, .hero-section, .cta-button)
  • Custom properties: kebab-case (--primary-color, --font-size-large)
  • BEM notation uses: block__element—modifier format (card__header--active)

Why these conventions exist

camelCase in JavaScript — Derived from early JavaScript conventions that followed Java, where camelCase was the standard. The spec’s built-in APIs use camelCase (getElementById, addEventListener), so following the same convention keeps user code consistent with the language itself.

snake_case in Python — Python’s PEP 8 style guide recommends snake_case because it’s more readable for most English words and aligns with how Python’s standard library was written.

kebab-case in URLs — Google has officially stated that hyphen-separated URLs are preferred over underscore-separated ones. Hyphens are treated as word separators in URL parsing; underscores join words. word-count appears to search engines as two words; word_count appears as one.

PascalCase for types and classes — Using a distinct casing for types visually distinguishes them from values, which is especially valuable in typed languages. User (type) vs. user (variable) are immediately identifiable.

Common mistakes

Inconsistent conventions in the same file — Mixing camelCase and snake_case variable names in the same JavaScript file, or switching between kebab and snake for CSS classes, makes code harder to read and suggests low attention to detail.

Wrong case for the context — camelCase column names in a database that other tools will query, or SCREAMING_SNAKE for regular variables. These technically work but violate conventions that other developers expect.

Case collisionsuser (variable) and User (class) in the same scope can cause confusion. Using PascalCase consistently for all types and classes prevents this.

Inconsistent file naming — Some files using kebab-case, others using camelCase in the same directory creates messy import statements and makes files harder to find.

Use Case Converter to transform text between any of these formats instantly — useful for renaming variables, converting database column names, generating slugs, or reformatting copied code snippets.


✨ Missing something?
Can't find the tool you need?
Request it — we build new tools based on what people ask for.
Request a tool