What snake_case is
snake_case replaces the spaces between words with underscores and keeps every letter lowercase:
First Namebecomesfirst_nameorderTotalAmountbecomesorder_total_amountis-logged-inbecomesis_logged_in
It is one of the easiest naming styles to read, because the underscore leaves a visible gap between words.
How the converter works
The tool finds the words in each line, lowercases them and joins them with underscores. It recognizes words separated by spaces, hyphens, dots or slashes, and it also splits camelCase and PascalCase names at their capital letters. Runs of capitals are kept together, so parseHTMLString becomes parse_html_string.
Every line is converted on its own, so you can paste a full list.
| Input | Output |
|---|---|
| User First Name | user_first_name |
| orderTotalAmount | order_total_amount |
| background-color | background_color |
| GetUserByID | get_user_by_id |
| Date of birth | date_of_birth |
Where snake_case is used
- Python: variables, functions and module names, as recommended by PEP 8
- Ruby: variables, methods and file names
- Rust: variables, functions and modules
- SQL databases: table and column names such as
created_at - File names: where spaces cause trouble in scripts and URLs
JavaScript and Java use camelCase for the same purpose, which is why converting between the two comes up so often when a frontend talks to a backend.
snake_case and its relatives
| Style | Example | Typical use |
|---|---|---|
| snake_case | max_retry_count | Variables, columns |
| CONSTANT_CASE | MAX_RETRY_COUNT | Constants, environment variables |
| kebab-case | max-retry-count | URLs, CSS classes |
| camelCase | maxRetryCount | JavaScript variables |
For constants and .env files, press CONSTANT_CASE in the tool. For URLs, use kebab-case. Search engines treat hyphens as word separators, which makes them the better choice in web addresses.
Tips for clean names
- Keep names short but complete:
user_emailis better thanueorthe_email_address_of_the_user. - Avoid a leading number. Most languages do not allow a name to start with a digit.
- Be consistent across a project. Mixed styles are harder to search and easier to mistype.