What Is snake_case and How Does It Format Identifiers?
snake_case is a programming identifier convention where all letters are lowercase and words are delimited by single ASCII underscores (_, U+005F).
snake_case is a naming convention where all words are lowercase and separated by underscores (_) with no spaces or punctuation (e.g., user_account_registration_timestamp).
What Regex & Tokenization Rule Does the snake_case Converter Use?
The converter splits input on non-alphanumeric delimiters (/[^\p{L}\p{N}]+/u) and lowercase-to-uppercase camelCase transitions (/(?<=\p{Ll})(?=\p{Lu})/u), then executes words.map(w => w.toLowerCase()).join("_").
- Worked Before / After Example: Input
User Account Registration Timestamp And Email(6 words, 45 characters) → Outputuser_account_registration_timestamp_and_email(1 identifier, 45 characters; 6 uppercase letters lowercased, 5 spaces replaced with_).
| Input Format / Transformation Rule | Input Example (Before) | Output Result (After) | Characters Changed (count) |
|---|---|---|---|
Title Words → snake_case |
User Account Email (18 chars, 3 words) |
user_account_email (18 chars, 1 token) |
3 letters lowercased, 2 spaces → _ |
camelCase → snake_case |
createdAtTimestamp (18 chars) |
created_at_timestamp (20 chars) |
+2 underscores inserted, 2 letters lowercased |
PascalCase → snake_case |
DatabaseConnectionPool (22 chars) |
database_connection_pool (24 chars) |
+2 underscores inserted, 3 letters lowercased |
kebab-case → snake_case |
oauth-refresh-token (19 chars) |
oauth_refresh_token (19 chars) |
2 hyphens → 2 underscores |
Where Is snake_case Used in Programming and Databases?
snake_case is the mandatory standard in Python (PEP 8), PostgreSQL/MySQL schema column names, Rust functions, and Ruby identifiers.
- Python: Variable names, function names, and module files (PEP 8).
- Relational Databases: SQL table names, column identifiers, and foreign keys.
- Rust & Ruby: Standard identifier convention.
- Configuration Files: YAML and JSON dictionary keys.