camelCase, snake_case, PascalCase — How Developers Use Case Conventions
If you've ever read someone else's code and felt confused by getUserById vs get_user_by_id vs GetUserById — you've encountered naming conventions. These aren't just stylistic preferences; in many languages and frameworks they carry meaning and affect how code runs.
This guide explains every major case convention used in programming, which languages use which, and how case converters help developers work faster.
The 7 Main Naming Conventions in Programming
| Convention | Example | How It Works |
|---|---|---|
| camelCase | getUserById | First word lowercase; each subsequent word capitalised |
| PascalCase | GetUserById | Every word starts with uppercase; also called UpperCamelCase |
| snake_case | get_user_by_id | All lowercase; words separated by underscores |
| SCREAMING_SNAKE_CASE | GET_USER_BY_ID | All uppercase; words separated by underscores |
| kebab-case | get-user-by-id | All lowercase; words separated by hyphens |
| UPPER_CASE | MAXRETRIES | All uppercase; often no separator (for short constants) |
| dot.case | get.user.by.id | Lowercase; words separated by dots (less common) |
Which Language Uses Which Convention?
JavaScript and TypeScript
const userId = "abc123";
function getUserProfile() { }
// Classes and interfaces — PascalCase
class UserProfile { }
interface ApiResponse { }
// Constants — SCREAMING_SNAKE_CASE
const MAX_RETRY_COUNT = 3;
// CSS classes — kebab-case
// .user-profile-card { ... }
| Element | Convention | Example |
|---|---|---|
| Variables | camelCase | firstName, isLoggedIn, totalPrice |
| Functions | camelCase | calculateTotal(), fetchUserData() |
| Classes | PascalCase | UserAccount, ProductCart |
| Constants | SCREAMING_SNAKE_CASE | API_BASE_URL, MAX_ITEMS |
| React components | PascalCase | LoginButton, NavBar |
| CSS / HTML attributes | kebab-case | background-color, data-user-id |
Python
user_name = "Mihad"
def get_user_profile(): pass
# Classes — PascalCase
class UserProfile:
pass
# Constants — SCREAMING_SNAKE_CASE
MAX_RETRIES = 3
# Private/internal — leading underscore
_internal_cache = {}
Python's PEP 8 style guide is explicit: snake_case for everything except classes. This is one of the most consistent naming schemes in any major language, and following it is expected in any professional Python codebase.
Dart and Flutter
String userName = 'Mihad';
void fetchUserData() { }
// Classes and widgets — PascalCase
class LoginScreen extends StatefulWidget { }
// Files — snake_case
// login_screen.dart, user_model.dart
// Constants — lowerCamelCase (Dart convention)
const kPrimaryColor = Colors.green;
| Element | Convention | Example |
|---|---|---|
| Variables, functions | camelCase | userName, fetchData() |
| Classes, Widgets, Enums | PascalCase | LoginScreen, UserModel |
| File names | snake_case | login_screen.dart |
| Constants (Flutter style) | kCamelCase | kPrimaryColor, kMaxItems |
| Library/package names | snake_case | flutter_bloc, get_it |
Java and Kotlin
String firstName = "Mihad";
void getUserById(int id) { }
// Classes — PascalCase
class UserRepository { }
// Constants — SCREAMING_SNAKE_CASE
static final int MAX_CONNECTIONS = 10;
HTML, CSS, and URLs
Web technologies almost universally use kebab-case — hyphens instead of underscores. This is because underscores in URLs and CSS selectors can cause issues with certain parsers and search engines.
.user-profile-card { background-color: #fff; }
<!-- HTML attributes — kebab-case -->
<div data-user-id="123" class="nav-bar">
// URLs — kebab-case
rankstreak.in/word-counter-online-free/
// NOT rankstreak.in/word_counter_online_free/
/word-counter/ is indexed as "word counter" (two separate words), while /word_counter/ is indexed as "word_counter" (one joined term). Always use hyphens in URLs for better SEO.Master Reference: Case Convention by Language
| Language | Variables/Functions | Classes | Constants | Files |
|---|---|---|---|---|
| JavaScript | camelCase | PascalCase | SCREAMING_SNAKE | camelCase or kebab |
| TypeScript | camelCase | PascalCase | SCREAMING_SNAKE | camelCase or kebab |
| Python | snake_case | PascalCase | SCREAMING_SNAKE | snake_case |
| Dart / Flutter | camelCase | PascalCase | kCamelCase | snake_case |
| Java | camelCase | PascalCase | SCREAMING_SNAKE | PascalCase |
| Kotlin | camelCase | PascalCase | SCREAMING_SNAKE | PascalCase |
| C# | camelCase | PascalCase | PascalCase | PascalCase |
| Go | camelCase | PascalCase | PascalCase | snake_case |
| Ruby | snake_case | PascalCase | SCREAMING_SNAKE | snake_case |
| PHP | camelCase | PascalCase | SCREAMING_SNAKE | snake_case |
| CSS | kebab-case | N/A | N/A | kebab-case |
| SQL | snake_case | N/A | UPPER_CASE | snake_case |
How Case Converters Help Developers Day-to-Day
Scenario 1: Converting API Response Keys
REST APIs often return JSON in snake_case (Python/Ruby backend convention), but your JavaScript frontend expects camelCase. Converting user_first_name → userFirstName across dozens of fields is tedious to do manually. A case converter handles it in one paste.
Scenario 2: Renaming Variables During Refactoring
When refactoring code or switching frameworks (e.g., from plain JS to React, or from Python to Dart), variable naming conventions change. Converting a list of variable names from snake_case to camelCase in bulk saves significant time.
Scenario 3: Converting Content to URL Slugs
Blog titles need to become URL slugs. "How to Use an Online Case Converter" → "how-to-use-an-online-case-converter". Converting to lowercase and then replacing spaces with hyphens is exactly what a case converter's lowercase mode does, getting you 80% of the way there.
Scenario 4: Database Column Naming
Database columns are typically snake_case. When mapping database columns to ORM model properties (which are often camelCase in application code), quickly converting between the two speeds up the mapping process.
🔤 Convert Text Case Instantly — Free
Sentence case, Title Case, UPPERCASE, lowercase — paste and convert in one click.
Open Case Converter →🔧 More Free Tools for Developers on RankStreak
- 🔤 Case Converter — Convert between text cases instantly
- 📊 Text to Binary — Convert text to binary code for CS learning
- 🔄 Text Reverser — Reverse strings for algorithm practice
- 📱 QR Code Generator — Generate QR codes for project demos and portfolios
- 🔐 Password Generator — Create secure API keys and test passwords
Frequently Asked Questions
Yes — significantly. In most languages, using the wrong convention doesn't break your code (except in specific cases like Python private attributes or Go's exported/unexported distinction), but it marks you as someone unfamiliar with the language's ecosystem. In professional and open-source codebases, consistent naming conventions are enforced by linters (ESLint, Pylint, dartanalyze) and code reviewers.
It's a design philosophy choice. Python's creator Guido van Rossum and PEP 8 (Python's style guide) standardised snake_case for readability — lowercase with underscores is considered easier to read for longer names like calculate_total_user_score vs calculateTotalUserScore. There's no technical reason one works better than the other; it's a community convention.
Both capitalise the first letter of each word, but PascalCase also capitalises the very first letter: UserProfile. camelCase starts lowercase: userProfile. PascalCase is also called UpperCamelCase, while camelCase is sometimes called lowerCamelCase.
kebab-case is best for URLs. Google treats hyphens as word separators (so "word-counter" is indexed as two separate words), making your pages more discoverable. Underscores join words together ("word_counter" is one term to Google). Uppercase letters in URLs create duplicate content risk. Always use lowercase kebab-case for URLs and slugs.
Conclusion
Naming conventions are the silent language of programming — they communicate intent, ownership, and context without a single comment. Mastering them makes your code more readable, more professional, and easier to maintain.
Quick cheat sheet to remember:
- camelCase → JavaScript/TypeScript variables and functions, Dart/Flutter variables
- PascalCase → Classes in almost every language, React components
- snake_case → Python everything, database columns, file names in Python/Dart/Ruby
- SCREAMING_SNAKE_CASE → Constants in most languages
- kebab-case → CSS classes, HTML attributes, URLs, file names in web projects