Back to Blog
Best Practices

Variable Naming Standards: camelCase, snake_case and More

2026-04-26 5 min read

Consistent naming of variables and functions is one of the foundations of clean, maintainable code. There are several widely adopted standards in the industry, each with its own use contexts.

The Main Standards

StandardExampleCommon Use
camelCaseuserNameJavaScript, Java, Dart
PascalCaseUserNameClasses, React Components, C#
snake_caseuser_namePython, Ruby, SQL
SCREAMING_SNAKEMAX_RETRIESConstants in all languages
kebab-caseuser-nameURLs, CSS, HTML attributes

camelCase

First word lowercase, subsequent words capitalized. Standard in JavaScript/TypeScript:

// JavaScript / TypeScript
const userName = "Ana";
let totalPrice = 100;
function fetchUserData() { ... }
const isLoggedIn = true;

PascalCase

All words capitalized. Used for classes, components and types:

// Classes
class UserAccount { ... }

// React Components
function LoginButton() { ... }
export default function UserProfile() { ... }

// TypeScript types and interfaces
interface ApiResponse { ... }
type UserRole = "admin" | "viewer";

snake_case

Words separated by underscores. Standard in Python and widely used in databases:

# Python
user_name = "Ana"
total_price = 100
def fetch_user_data():
    pass

-- SQL
SELECT user_name, created_at FROM users
WHERE is_active = true

SCREAMING_SNAKE_CASE

All uppercase with underscores. Reserved for constants that don't change:

// Configuration constants
const MAX_RETRY_ATTEMPTS = 3;
const API_BASE_URL = "https://api.example.com";
const DEFAULT_TIMEOUT_MS = 5000;

kebab-case

Words separated by hyphens. Ideal for URLs, CSS classes and HTML attributes:

/* CSS */
.nav-bar { }
.primary-button { }
.user-profile-card { }

<!-- HTML -->
<div class="main-container" data-user-id="1">

/* URLs */
/blog/essential-git-commands
/tools/color-palette

General Good Naming Rules

  • Be descriptive: userAge is better than a or x
  • Avoid confusing abbreviations: temperature > tmp
  • Use verbs for functions: getUser(), sendEmail(), isValid()
  • Use nouns for variables: user, orderList, errorMessage
  • Use boolean prefixes: isActive, hasPermission, canEdit
  • Be consistent: if your team picks a standard, everyone follows it

Per Language: Quick Summary

JavaScript/TypeScript:
  Variables & functions → camelCase
  Classes & components  → PascalCase
  Constants             → SCREAMING_SNAKE_CASE

Python:
  Variables & functions → snake_case
  Classes               → PascalCase
  Constants             → SCREAMING_SNAKE_CASE

CSS/HTML:
  Classes & IDs         → kebab-case

Database (SQL):
  Columns & tables      → snake_case

Generating slugs for your URLs? Try our Slug Generator tool.

Slug Generator