If you write code, you have seen both camelCase and snake_case. Teams argue about them because languages, databases, and APIs disagree by default. This guide gives clear rules, shows where PascalCase and kebab-case fit, and links you to a free in-browser converter so you can rename identifiers without uploading a file.
What is camelCase?
camelCase starts with a lowercase letter, and each later word starts with an uppercase letter — no spaces or underscores.
Examples: firstName, lastName, getUserProfile, httpResponseCode
What is snake_case?
snake_case uses lowercase letters with words separated by underscores.
Examples: first_name, last_name, get_user_profile, http_response_code
Quick decision: which should you use?
| You are writing… | Prefer | Why |
|---|---|---|
| JavaScript / TypeScript variables & functions | camelCase | Language convention (ESLint / Prettier ecosystems) |
| TypeScript / C# / Java types & classes | PascalCase | Types read as nouns; matches mainstream style guides |
| Python / Ruby | snake_case | PEP 8 and Ruby community defaults |
| PostgreSQL / MySQL columns | snake_case | SQL identifiers stay readable without quoting |
| HTTP path segments & CSS custom properties | kebab-case | URLs and CSS already use hyphens |
| Environment variables | UPPER_SNAKE_CASE | Shell-safe, traditional for config |
Rule of thumb: match the language or store you are inside. Convert at the boundary (API JSON ↔ DB columns) instead of inventing a house style that fights every library.
When to use camelCase
| Context | Convention | Example |
|---|---|---|
| JavaScript variables | camelCase | userName |
| JavaScript functions | camelCase | calculateTotal() |
| TypeScript interfaces | PascalCase | UserProfile |
| Java variables | camelCase | accountBalance |
| C# properties | PascalCase | FirstName |
| Swift properties | camelCase | viewController |
When to use snake_case
| Context | Convention | Example |
|---|---|---|
| Python variables | snake_case | user_name |
| Python functions | snake_case | calculate_total() |
| Ruby variables | snake_case | account_balance |
| PostgreSQL columns | snake_case | created_at |
| JSON keys (many backends) | snake_case | first_name |
| Environment variables | UPPER_SNAKE_CASE | DATABASE_URL |
| CSS custom properties | kebab-case | --primary-color |
| URLs / slugs | kebab-case | /blog/my-post |
Language-by-language examples
JavaScript / TypeScript — camelCase
const firstName = "John";
function getUserProfile() { }
const httpResponseCode = 200;
Python — snake_case
first_name = "John"
def get_user_profile():
pass
http_response_code = 200
Database columns — snake_case
CREATE TABLE users (
first_name VARCHAR(100),
created_at TIMESTAMP,
is_active BOOLEAN
);
PascalCase and kebab-case (the neighbors)
- PascalCase (
UserProfile): same word breaks as camelCase, but the first letter is uppercase. Use for classes, React components, and type names. - kebab-case (
user-profile): lowercase with hyphens. Use for URL slugs, CSS classes, and HTMLdata-*style attributes — not for most programming-language identifiers.
If you are stuck renaming a batch of keys, convert once at the edge rather than mixing styles inside one module.
Convert without rewriting by hand
Need camelCase ↔ snake_case (or PascalCase / kebab-case) on a list of names? Use CaseShift — free, runs in your browser, nothing uploaded.
Related: uppercase ↔ lowercase guide when you only need letter case, not word separators.
Related ToolBookly tools
Renamed a batch of JSON keys at an API ↔ DB boundary? Pretty-print and validate the payload locally with JSONly — format, minify, sort keys, and tree-view in your browser with no upload; optional share links live only in the URL fragment and never expire. Need a regex to rewrite identifiers before you convert? Try Regexly — pattern test in the browser, no upload.
Chinese UI: CaseShift 中文