Skip to content

camelCase vs snake_case vs kebab-case: Which to Use

Last updated: March 16, 2026

This guide compares camelCase, snake_case, and kebab-case naming conventions and explains which to use in each programming language. Read on to learn the conventions and try the free converter tool.

What is this?

When to use camelCase, snake_case, or kebab-case in programming. Language conventions, examples, and a free converter tool.

Who needs it?

Developers, designers, content creators, and anyone who needs to quickly generate text, codes, or identifiers.

Bottom line

100% free, runs entirely in your browser — no signup, no data sent to any server.

What Is the camelCase Convention?

camelCase joins words with no spaces, capitalizing each new word except the first (e.g., myVariableName). It is the dominant naming convention in JavaScript, Java, TypeScript, Swift, and most object-oriented languages for variables, functions, and method names.

JavaScript: const firstName = "Alice";

Java: String firstName = "Alice";

There is an important distinction between lowerCamelCase and UpperCamelCase (PascalCase). PascalCase capitalizes the first letter too (e.g., UserProfile). PascalCase is used for class names, constructors, React components, and TypeScript interfaces.

What Is the snake_case Convention?

snake_case joins words with underscores, all lowercase (e.g., my_variable_name). It is the standard naming convention in Python, Ruby, PHP variables, and SQL column names.

Python: first_name = "Alice"

SQL: SELECT first_name FROM users

There is also SCREAMING_SNAKE_CASE, which uses all uppercase letters with underscores. It is the universal convention for constants across nearly all programming languages: MAX_RETRIES = 3

What Is the kebab-case Convention?

kebab-case joins words with hyphens, all lowercase (e.g., my-variable-name). It is used in CSS properties, HTML attributes, URL slugs, and file names.

CSS: background-color: #fff;

URL: https://example.com/my-blog-post

kebab-case cannot be used for variable names in most programming languages because hyphens are interpreted as the subtraction operator. Writing my-variable would be parsed as my minus variable, causing a syntax error. This is why kebab-case is restricted to contexts like CSS, URLs, and file naming.

Which Convention Should You Use?

The answer depends on the language or context. Here is a quick reference for the most common scenarios:

Language / ContextConventionExample
JavaScript variablescamelCasefirstName
JavaScript classesPascalCaseUserProfile
Python variablessnake_casefirst_name
Python constantsSCREAMING_SNAKE_CASEMAX_VALUE
SQL columnssnake_casefirst_name
CSS propertieskebab-casebackground-color
HTML attributeskebab-casedata-user-id
URL slugskebab-casemy-blog-post
File nameskebab-case or snake_casemy-component.tsx

Converting Between Different Case Styles

Switching between naming conventions is common when working across languages or APIs. A JavaScript frontend using camelCase often consumes a Python API that returns snake_case keys. Similarly, CSS class names in kebab-case need to be referenced as camelCase strings in JavaScript style objects.

Serialization libraries (like humps for JS or pydantic alias generators in Python) can automate these conversions. For quick one-off transforms, you can use our free converter:

Convert your text instantly with our free Snake/Kebab Case Converter →

Frequently Asked Questions About Camelcase Vs Snake Case

Is camelCase or snake_case more readable?

Research suggests snake_case is slightly more readable for non-programmers due to visual word separation. camelCase is more compact. Most developers follow their language convention rather than choosing based on readability alone.

Why can't I use kebab-case in JavaScript?

Hyphens are interpreted as the subtraction operator in JavaScript. my-variable would be parsed as my minus variable. Use camelCase for JS variables and PascalCase for classes.

What is PascalCase?

PascalCase (also called UpperCamelCase) capitalizes the first letter of every word including the first (e.g., MyClassName). Used for class names and constructors in most OOP languages, React components, and TypeScript interfaces.

What case style does Google recommend for URLs?

Google recommends kebab-case for URLs. Google has stated that hyphens are treated as word separators while underscores are not, making kebab-case better for SEO in URL slugs.

Can I mix naming conventions in one project?

Yes — it is common to use camelCase for JavaScript variables and kebab-case for CSS classes in the same project. The key is consistency within each context (all JS vars in camelCase, all CSS classes in kebab-case).

More Free Text Tools

Explore naming conventions and convert text with our other free tools.