snake_case is the conventional naming style for Python identifiers and SQL columns: all lowercase, with underscores between words. This converter rewrites any phrase or differently-cased identifier into clean snake_case.
How it works
The input is normalised into a list of lowercase word tokens, then joined with underscores. Word boundaries come from separators and from case transitions in camelCase or PascalCase input:
"User Profile Id" -> user_profile_id
"userProfileId" -> user_profile_id
"user-profile-id" -> user_profile_id
"HTTPServer" -> http_server
Each detected word is lowercased before joining, so the result is always a valid, lowercase, underscore-separated identifier.
Tips and notes
Acronyms are lowercased, so parseHTML becomes parse_html. Letters and digits
are split during tokenisation; if you want v2 to stay together, rejoin it
after copying. The output is safe to use directly as a Python variable name or
SQL column, provided it does not begin with a digit.
When to use snake_case
Different communities have different naming conventions, and knowing which convention to apply where avoids code review friction:
| Context | Convention | Example |
|---|---|---|
| Python variables and functions | snake_case | user_profile_id |
| Python modules and packages | snake_case | data_utils.py |
| SQL column names | snake_case | created_at |
| SQL table names | snake_case or SCREAMING_SNAKE | user_accounts |
| JavaScript/TypeScript variables | camelCase | userProfileId |
| CSS class names | kebab-case | user-profile-id |
| URL slugs | kebab-case | /user-profile |
| Constants (Python, many languages) | SCREAMING_SNAKE_CASE | MAX_RETRY_COUNT |
How the converter handles different inputs
The converter detects word boundaries from multiple source formats in a single pass:
From natural language phrases — Spaces split the phrase into words, each word is lowercased, underscores join them.
"User Profile ID" → user_profile_id
From camelCase — Each transition from a lowercase letter to an uppercase letter is a word boundary.
"userProfileId" → user_profile_id
From PascalCase — Same as camelCase but the first word also starts with uppercase.
"UserProfileId" → user_profile_id
From kebab-case — Hyphens are treated as word separators and removed.
"user-profile-id" → user_profile_id
From SCREAMING_SNAKE_CASE — Underscores are already separators; everything is lowercased.
"USER_PROFILE_ID" → user_profile_id
Acronym handling
Consecutive uppercase letters (acronyms) are treated as a single word:
"HTTPSServer" → https_server
"parseHTML" → parse_html
"parseHTMLDoc" → parse_html_doc
This matches Python’s PEP 8 recommendation: treat acronyms as single lowercase words (html_parser, not h_t_m_l_parser).
Practical workflow: renaming database columns
If you are migrating a database schema from a framework that used camelCase column names (common in JavaScript ORMs) to a PostgreSQL-native convention:
- List the column names from your ORM or schema file
- Paste each name into this converter
- Copy the snake_case output
- Use it in your migration script
For example, a migration converting createdAt, updatedAt, and userId produces created_at, updated_at, and user_id — the standard PostgreSQL column style.