Convert Text to snake_case for Python, Ruby, and Database Columns
snake_case writes a phrase in lowercase with underscores between the words, like
user_profile_image. It is the standard for variables and functions in Python
and Ruby, for column names in SQL databases, and for environment variables in its
all-caps form (SCREAMING_SNAKE_CASE). This converter rewrites text from any
common naming style into snake_case, one line at a time, entirely in your browser.
Why underscores instead of hyphens?
Because a hyphen is a minus sign. In Python, Ruby, SQL, and most other languages,
user-profile parses as "user minus profile", so hyphenated names simply are
not valid identifiers. The underscore is treated as an ordinary word character, which is
why snake_case became the convention wherever a name has to be a real identifier. Use
kebab-case instead when the name lives in a URL, a
CSS class, or a file name, where hyphens are the norm.
How are acronyms and numbers handled?
A run of capitals is kept as one word and split before the last capital when a lowercase
letter follows, so XMLHttpRequest becomes xml_http_request and
parseHTMLString becomes parse_html_string. Digits are isolated
as their own word on both sides: user2Name becomes
user_2_name and version2point0 becomes
version_2_point_0. That matches the
dot.case and
kebab-case converters, and differs from
camelCase and
PascalCase, which have no separator to make an
isolated digit readable.
What happens to punctuation and accented text?
Punctuation of any kind is treated as a separator and dropped, so
Hello, World! becomes hello_world and
user@example.com becomes user_example_com. Accented and
non-Latin letters are preserved as ordinary letters — café naïve
converts to café_naïve, and Devanagari, Hebrew, and Thai text keeps its
vowel marks intact rather than being broken apart.
Where is snake_case used?
Python mandates it in PEP 8 for variables, functions, methods, and
modules. Ruby uses it for methods and variables, with PascalCase reserved
for classes. SQL databases conventionally use it for table and column
names, partly because unquoted identifiers are case-insensitive in most engines, so
underscores are the only reliable word separator. Rust enforces it for
functions and variables via a compiler lint. And in its uppercase form it is the near
universal convention for constants and environment variables, from
MAX_RETRIES to DATABASE_URL.
Last reviewed: August 2026