What is snake_case?
snake_case is a naming convention where all letters are lowercase and words are separated by underscores. The name comes from the way the underscores connect the words at ground level, like a snake.
It's the standard convention in Python, Ruby, Rust, SQL, and most Unix-derived contexts.
When to use snake_case
- Python variables and functions — PEP 8 mandates snake_case.
- Ruby methods and variables.
- Rust function and variable names.
- SQL column and table names.
- YAML and TOML keys in configuration files.
- Bash variables and shell-script identifiers.
- Database identifiers across most RDBMS conventions.
How snake_case conversion works
- Input is tokenized using the smart tokenizer: spaces, hyphens, dots, slashes split words; camelCase humps split (so
getUserName→get+User+Name); ALLCAPS acronym runs are recognized as single tokens (soHTMLParserbecomeshtml_parser, noth_t_m_l_parser). - Each word is lowercased.
- Words are joined with a single underscore between them.
Worked examples
| Input | snake_case |
|---|---|
user name |
user_name |
XMLHttpRequest |
xml_http_request |
getElementById |
get_element_by_id |
isUserLoggedIn |
is_user_logged_in |
Related case formats
CONSTANT_CASE
→ Convert text to CONSTANT_CASE
kebab-case→ Convert text to kebab-case
camelCase→ Convert text to camelCase
Need more conversion options?
Open the full converter →