camelCase vs snake_case vs PascalCase โ When to Use Each in Code
Different languages have different conventions. JavaScript uses camelCase for variables, Python uses snake_case, classes use PascalCase. Here is the full guide.
The naming convention you use in code isn't just a style preference. In many contexts it affects whether code runs at all, whether it integrates with existing APIs, and whether other developers on your team can read it without confusion. Understanding when to use camelCase versus snake_case saves you debugging time and code review friction.
camelCase: JavaScript's default
camelCase starts with a lowercase letter and capitalizes the first letter of each subsequent word. No separators. Like the humps on a camel.
// JavaScript - use camelCase for variables and functions
const userName = "Alice";
function getUserProfile(userId) { ... }
const isLoggedIn = true;JavaScript, TypeScript, Java, Swift, and Kotlin all use camelCase for variables, functions, and object properties. If you're writing any of these languages, camelCase is the default. Deviating from it makes your code look foreign to the ecosystem.
snake_case: Python and databases
snake_case uses all lowercase with underscores between words. Python's PEP 8 style guide mandates it for variables and functions. SQL column names and table names conventionally use it as well.
# Python - snake_case for everything user_name = "Alice" def get_user_profile(user_id): ... is_logged_in = True -- SQL columns SELECT user_name, created_at FROM user_profiles;
PascalCase: classes and components
PascalCase capitalizes every word, including the first. It's used for class names across almost every language, and it's mandatory for React component names (React uses the case to distinguish components from HTML elements).
// React component - must be PascalCase
function UserProfile() { return <div>...</div> }
// Python class
class UserProfile:
passkebab-case: URLs and CSS
kebab-case uses hyphens between words, all lowercase. URLs use it (/blog/camelcase-vs-snake-case-guide). CSS class names use it (.nav-link, .hero-section). HTML data attributes use it (data-user-id). You can't use kebab-case as a JavaScript variable name because hyphens are subtraction operators.
SCREAMING_SNAKE_CASE: constants
Environment variables, configuration constants, and magic numbers use this. MAX_RETRY_COUNT, API_BASE_URL, DEFAULT_TIMEOUT_MS. The all-caps signals "this value doesn't change."
Convert any text between naming conventions instantly with the Case Converter tool.