/sneɪk keɪs/
noun — “the naming style where words slither along with underscores connecting them.”
Snake_case is a naming convention in programming where all letters are lowercase and words are separated by underscores (_). This style is widely used for variable names, function names, file names, and database columns, particularly in languages like Python, Ruby, and C, where hyphens or spaces are not allowed. The underscores serve as visible boundaries between words, improving readability without relying on capitalization.
Compared to camelCase or PascalCase, snake_case emphasizes uniform lowercase letters and explicit separators. This makes it easier to type, search, and parse programmatically, especially in environments that are case-sensitive or when identifiers are shared between different systems. It pairs naturally with Variable Naming and Naming Convention guidelines to ensure clarity and consistency.
In practice, snake_case is often the default style for Python variables and function names, as recommended by PEP 8, but it also appears in configuration files, JSON keys, and database schemas. For example, it works hand-in-hand with Code Quality and Best Practice standards, helping developers maintain readable, maintainable, and predictable identifiers across projects.
A few practical examples of snake_case in real code show its versatility:
// Python variables and functions
user_name = "alex"
total_item_count = 42
def calculate_total_price(items):
return sum(item.price for item in items)
# Database column names
CREATE TABLE users (
user_id INT PRIMARY KEY,
email_address VARCHAR(255),
account_status VARCHAR(20)
);
# Configuration keys
max_upload_size=1048576
enable_dark_mode=trueKey considerations when using snake_case include consistency within a project and alignment with language or framework conventions. Arbitrarily mixing snake_case with camelCase or PascalCase can reduce readability and confuse collaborators, so it’s common to reserve snake_case for certain identifiers while using other conventions for classes or constants.
Snake_case is like a garden hose laid out straight with clear sections: you can trace the path without stepping on anyone’s toes.
See camelCase, PascalCase, kebab-case, Naming Convention, Variable Naming.