Snake Case Converter
Paste any phrase, variable name, or identifier. The converter lowercases the text, replaces spaces and punctuation with underscores, and collapses repeats. Toggle UPPER_SNAKE_CASE for constants or kebab-case for URL slugs.
What snake_case is and where it comes from
snake_case is the convention of writing multi-word identifiers in lowercase, joining the words with underscores: user_profile_id, get_total_revenue, max_retry_count. The name comes from the underscore looking vaguely like a snake's body between words. It first appeared in C in the 1970s and became the dominant identifier style in Python, Ruby, Rust, and Elixir. See also: camelCase converter.
The two related variants are:
- UPPER_SNAKE_CASE (also called SCREAMING_SNAKE_CASE): used for constants in most languages that use snake_case.
MAX_RETRY_COUNT,DATABASE_URL. - kebab-case (also called spinal-case or dash-case): same as snake_case but with hyphens instead of underscores. Standard for URL slugs, CSS class names, and Lisp identifiers.
The converter on this page produces all three (plus camelCase for compatibility checks) so you can copy the style your codebase uses.
How the conversion works
The converter applies four rules in order:
- Split on whitespace, punctuation, and camelCase boundaries. "User ID", "user-id", "userId", and "user_id" all produce the token list
["user", "id"]. - Lowercase each token.
- Join with the chosen separator. Underscore for snake, hyphen for kebab, nothing for camel (then capitalize each token after the first).
- For UPPER_SNAKE_CASE, uppercase the whole result.
Numbers stay where they were in the input and join with the surrounding token via the separator. Leading non-letter characters get stripped (so "1user" becomes "user"; if you need to preserve the leading digit, use a different conversion).
When to use snake_case (and when not to)
The convention is locked in by language community:
- Python. PEP 8 specifies snake_case for variables, functions, and methods. Class names use PascalCase. Constants use UPPER_SNAKE_CASE.
- Ruby. snake_case for methods, variables, and file names. CamelCase for class and module names.
- Rust. snake_case for functions, variables, modules. PascalCase for types and traits.
- Elixir. snake_case throughout, except modules (PascalCase).
- SQL. snake_case for table and column names is the dominant convention.
- JavaScript / TypeScript. camelCase for variables and functions, PascalCase for classes. snake_case is rare except in DB-mapping code.
- Java / C#. camelCase for methods and variables; PascalCase for classes and constants are SCREAMING_SNAKE_CASE.
If you're naming a URL slug or a CSS class, use kebab-case (hyphens) - it's the web convention.
Snake case vs camelCase: the long-running debate
There is empirical research on this. A 2010 study by Bonita Sharif and Jonathan Maletic ("An Eye Tracking Study on camelCase and under_score Identifier Styles") found that snake_case was 13% faster to read for identifier-recognition tasks, with fewer eye-tracking fixations. A follow-up study in 2011 was less conclusive but trended the same direction.
That said, language convention beats individual preference almost every time. Python code mixed with camelCase reads as broken; Java code mixed with snake_case reads as broken. Match your language community's convention and move on.
Frequently asked questions
What is snake_case?
snake_case is the convention of writing multi-word identifiers in lowercase letters joined by underscores: user_profile_id, get_total_revenue. It's the dominant identifier style in Python, Ruby, Rust, and Elixir.
What's the difference between snake_case and SCREAMING_SNAKE_CASE?
SCREAMING_SNAKE_CASE (also called UPPER_SNAKE_CASE) is snake_case in all capitals. It's the convention for constants in most snake-case languages: MAX_RETRIES, API_KEY.
What's kebab-case?
kebab-case (also spinal-case or dash-case) joins words with hyphens instead of underscores: user-profile-id. It's the convention for URL slugs, CSS class names, and Lisp identifiers.
How does the converter handle "userID" with mixed case?
The converter detects camelCase boundaries (a lowercase letter followed by an uppercase letter) and splits there. "userID" becomes the tokens ["user", "i", "d"] and joins to "user_i_d". For preserved acronyms, type your input as "user id" instead.
Does the converter preserve digits?
Yes, digits stay with their adjacent token. "version 1" produces "version_1". A leading digit alone gets dropped because most languages don't allow identifiers starting with a digit.
What about non-ASCII characters?
The converter's split regex treats only A-Z, a-z, and 0-9 as identifier characters. Accented letters and other non-ASCII pass through if they fall in a token but may cause split issues. For internationalized identifier conversion, use a Unicode-aware tool.
Why is snake_case more readable?
A 2010 eye-tracking study (Sharif and Maletic) found snake_case 13% faster to read for identifier-recognition than camelCase, with fewer fixations. The underscores serve as explicit word boundaries that don't require visual case-shift detection.
Which case style should I use?
Match your language community. Python and Ruby use snake_case for variables. JavaScript and Java use camelCase. CSS and URLs use kebab-case. Constants in most languages use UPPER_SNAKE_CASE. See also: Case Converter. See also: Title Case Converter.
Related tools
More wordcounter.ai tools
Other tools you might find useful.