Naming Conventions: camelCase, snake_case, kebab-case Explained
A practical guide to the casing conventions used across programming languages, frameworks, and platforms.
Programming has surprisingly many ways to write a multi-word name. Most communities have settled on conventions, and following them isn't pedantry — it's a courtesy that lets the next developer read your code without friction.
The casing zoo
- camelCase — first word lowercase, subsequent words capitalized. userProfile
- PascalCase — every word capitalized. UserProfile
- snake_case — lowercase, words joined by underscores. user_profile
- SCREAMING_SNAKE_CASE — uppercase snake_case. USER_PROFILE
- kebab-case — lowercase, words joined by hyphens. user-profile
- Train-Case — capitalized words joined by hyphens. User-Profile
- dot.case — lowercase, words joined by dots. user.profile
Convert any name: Paste in one case, get every variation instantly.
Open Case Converter →Conventions by language
| Language | Variables | Functions | Classes/Types | Constants |
|---|---|---|---|---|
| JavaScript / TypeScript | camelCase | camelCase | PascalCase | SCREAMING_SNAKE |
| Python | snake_case | snake_case | PascalCase | SCREAMING_SNAKE |
| Java | camelCase | camelCase | PascalCase | SCREAMING_SNAKE |
| Go | camelCase / PascalCase* | camelCase / PascalCase* | PascalCase | PascalCase |
| Rust | snake_case | snake_case | PascalCase | SCREAMING_SNAKE |
| C# | camelCase | PascalCase | PascalCase | PascalCase |
| SQL | snake_case | — | — | — |
* In Go, capitalization controls visibility: PascalCase is exported, camelCase is private to the package.
Conventions by context
- URLs: kebab-case (
/user-profile) — readable, no encoding needed. - CSS class names: kebab-case (
.user-profile) — matches CSS naming tradition. - HTML attributes: kebab-case (
data-user-id) — required by spec for custom data attributes. - HTTP headers: Train-Case (
Content-Type) — case-insensitive but conventionally Train-Case. - Environment variables: SCREAMING_SNAKE (
DATABASE_URL) — universal Unix convention. - JSON keys: usually camelCase (matches JavaScript) or snake_case (matches Python).
- File names: kebab-case (
user-profile.tsx) is most common in JS/TS; snake_case in Python/Ruby; PascalCase for class files in Java/C#.
JSON: the cross-cultural minefield
JSON traveled between every language ecosystem, so naming conventions vary. Common practices:
- JavaScript/Node APIs: camelCase (
{"firstName": "Ada"}) - Python/Ruby APIs: snake_case (
{"first_name": "Ada"}) - Public APIs serving multiple languages: often snake_case for clarity
When consuming third-party APIs, accept their convention; don't force your local style. Use mapping libraries (Jackson, Gson, attrs) to translate between JSON keys and your in-language field names.
Practical tips
- Follow the convention of the existing codebase over personal preference.
- Use auto-formatters (Prettier, Black, gofmt) — they don't change names but enforce a clean baseline.
- Use linters like ESLint and pylint to catch convention violations.
- Don't rename across the codebase just because you prefer a different convention. Pick your battles.