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

What camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE look like, and which one is standard in Python, JavaScript, CSS, URLs and databases.

Programmers cannot use spaces in names, so they join words in different ways. Each style has a name, and most languages and tools have a convention for which one to use.

To switch text between these styles, use the case converter.

Try the Case Converter. UPPERCASE, lowercase, Title Case, camelCase and more

Open the calculator

The styles at a glance

Style Example How it joins words
camelCase monthlyPayment First word lowercase, later words capitalized
PascalCase MonthlyPayment Every word capitalized
snake_case monthly_payment Lowercase, joined with underscores
kebab-case monthly-payment Lowercase, joined with hyphens
CONSTANT_CASE MONTHLY_PAYMENT Uppercase, joined with underscores

Common conventions by language

JavaScript and TypeScript - Variables and functions: camelCase - Classes and React components: PascalCase - Constants: often CONSTANT_CASE

Python (from the PEP 8 style guide) - Variables and functions: snake_case - Classes: PascalCase (PEP 8 calls it CapWords) - Constants: CONSTANT_CASE

Java and C# - Classes: PascalCase - Methods and variables: camelCase in Java; C# uses PascalCase for public methods

CSS and HTML - Class names and custom properties: usually kebab-case, such as .tool-panel

Databases - Table and column names: snake_case is the most common choice

Advertisement

kebab-case for web addresses

Use hyphens to separate words in URLs, such as /loan-calculator/. Google's guidance for URLs recommends hyphens rather than underscores, because hyphens are read as word separators. Every page on Calcrisp uses kebab-case addresses for this reason.

Why it matters

  • Readability. Consistent names make code easier to scan.
  • Tools. Linters and frameworks often expect the standard style and warn when you break it.
  • Teamwork. Following the language's convention means other developers know what to expect.

The most important rule is consistency: follow the convention of the language or project you are working in.

Acronyms

Styles differ on acronyms. Many style guides prefer treating them as words: parseHtml and HtmlParser rather than parseHTML and HTMLParser, because the word boundaries stay clear. Check your team's style guide.

The bottom line

Use camelCase for JavaScript variables, PascalCase for classes, snake_case for Python and databases, kebab-case for CSS and URLs, and CONSTANT_CASE for constants. Paste any phrase into the case converter to get each form instantly. For writing rather than code, see our title case rules.