camelCase vs snake_case vs kebab-case
4 min read · Developer fundamentals
The five main naming styles
| Style | Example | Character |
|---|---|---|
| camelCase | getUserName | Starts lowercase, capitals for each new word |
| PascalCase | GetUserName | Like camelCase but first letter is also capital |
| snake_case | get_user_name | All lowercase, words separated by underscores |
| kebab-case | get-user-name | All lowercase, words separated by hyphens |
| SCREAMING_SNAKE_CASE | GET_USER_NAME | All 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
| Language | Variables/Functions | Classes | Constants |
|---|---|---|---|
| JavaScript / TS | camelCase | PascalCase | UPPER_SNAKE |
| Python | snake_case | PascalCase | UPPER_SNAKE |
| Go | camelCase | PascalCase | PascalCase |
| CSS | kebab-case | kebab-case | --kebab-case |
| SQL | snake_case | snake_case | UPPERCASE |
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 →