camelCase vs snake_case vs kebab-case: Naming Conventions Explained

camelCase vs snake_case vs kebab-case: Naming Conventions Explained

Programmers can't use spaces in names, so they join words in a few standard ways. camelCase joins words with capitals, snake_case uses underscores, and kebab-case uses hyphens. Each language has its own habit, and following it makes your code easier for others to read. Here is what each style looks like and where to use it.

Need to convert a name? Paste it into the Text Case Converter and switch between camelCase, PascalCase, snake_case, CONSTANT_CASE and kebab-case in one click. Put one name per line to convert a whole list.

Open the Text Case Converter

The five styles at a glance

StyleExampleHow it works
camelCaseuserFirstNameFirst word lowercase, each next word capitalized
PascalCaseUserFirstNameEvery word capitalized, including the first
snake_caseuser_first_nameAll lowercase, words joined with underscores
SCREAMING_SNAKE_CASEUSER_FIRST_NAMEAll uppercase with underscores
kebab-caseuser-first-nameAll lowercase, words joined with hyphens

PascalCase is also called UpperCamelCase or StudlyCaps. SCREAMING_SNAKE_CASE is also called CONSTANT_CASE. kebab-case is sometimes called dash-case or spinal-case.

Which style each language uses

Language or contextVariables and functionsClassesConstants
JavaScript / TypeScriptcamelCasePascalCaseSCREAMING_SNAKE_CASE
Python (PEP 8)snake_casePascalCaseSCREAMING_SNAKE_CASE
PHP (PSR-1)camelCase methodsPascalCaseSCREAMING_SNAKE_CASE
JavacamelCasePascalCaseSCREAMING_SNAKE_CASE
C#camelCase locals, PascalCase methodsPascalCasePascalCase
SQL tables and columnssnake_casen/an/a
CSS classes, HTML attributeskebab-casen/an/a
URLs and file names on the webkebab-casen/an/a

Real examples by framework

Laravel: model classes are PascalCase and singular (OrderItem), database tables are snake_case and plural (order_items), columns are snake_case (created_at), and route URLs are kebab-case (/order-items). Laravel relies on these names to link models to tables automatically.

Vue.js: component files and names use PascalCase (UserCard.vue). In templates written directly in HTML they are written in kebab-case (<user-card>), because HTML is not case-sensitive. Props are camelCase in JavaScript and kebab-case in those templates.

Django / Flask: functions, variables and URL names are snake_case (get_user_profile), and model classes are PascalCase (UserProfile).

React: components must be PascalCase (UserCard). A lowercase name is treated as a plain HTML tag.

Why kebab-case wins for URLs

Google recommends hyphens instead of underscores in URLs, because hyphens clearly separate words for both people and search engines. So /text-case-converter is better than /text_case_converter or /textCaseConverter. Use the URL Slug Generator to turn any title into a kebab-case slug, and see how to create an SEO-friendly URL slug for the full rules.

What about JSON keys?

There is no single rule. JavaScript-based APIs usually use camelCase (firstName), while many Python and Ruby APIs use snake_case (first_name). Pick one and use it for the whole API. You can check a response with the JSON Formatter to make keys easy to read.

Common mistakes

Writing headings instead of code? The title case rules cover which words to capitalize in a title.

Paste words or an existing name like getUserID and get camelCase, PascalCase, snake_case, CONSTANT_CASE or kebab-case instantly.

Convert a name

Frequently asked questions

Is camelCase the same as PascalCase?

Nearly. camelCase starts with a lowercase letter (userName), PascalCase starts with a capital (UserName).

Why does Python use snake_case?

Python’s official style guide, PEP 8, recommends snake_case for functions and variables because it reads easily.

Should I use underscores or hyphens in file names?

For web pages and images, use hyphens. For Python modules, use underscores, because hyphens break imports.

What case should database columns use?

snake_case is the most common choice in MySQL and PostgreSQL, and it avoids quoting problems with capital letters.

Related articles

← All guides