How To Convert Text To snake_case
Learn what snake_case is, why Python and SQL favor it, and how to convert any phrase into a snake_case identifier.
Quick Answer
This snake case converter (also called underscore case) writes everything in lowercase and joins words with an underscore separator: "user profile image" becomes "user_profile_image". It produces the standard python variable name style for variables and functions, and is equally common for SQL database columns.
Try The snake_case Converter →Where snake_case Is Used
Python uses snake_case for almost everything except class names. SQL traditionally uses it for database columns and table names because keywords are case-insensitive and lowercase identifiers behave consistently, so learning how to convert a label to a snake_case column name pays off fast. The all-caps variant, SCREAMING_SNAKE_CASE, is common for constants, which is also how to make an env-var-friendly key once you uppercase the result.
How The Conversion Works
The converter splits your text into words at spaces, hyphens, underscores, and camelCase humps, lowercases each word, and joins them with underscores. For example, "getUserProfile", "get-user-profile", and "Get User Profile" all become "get_user_profile". Every line is converted on its own, so you can transform a whole column of names at once.
This tool is free and runs online entirely in your browser. Your text stays on your device, protecting your privacy: nothing is uploaded to a server, and results appear instantly.
Examples
A database column name. For example, "First Name" becomes "first_name", a clean database column name that sorts and quotes predictably in SQL.
Python naming for a function. For example, "getUserProfile" becomes "get_user_profile", the Python naming style for functions and variables.
Common Mistakes
snake_case vs Other Naming Conventions
snake_case is one of several alternatives for naming identifiers. camelCase is the standard for JavaScript, Java, and Swift: no separators, capital letter marks each word. kebab-case uses hyphens instead of underscores and is common for CSS and URL slugs, but most programming languages cannot use it for variable names. PascalCase is used for class names in most languages. snake_case's main advantage over these alternatives is readability: every word is lowercase and clearly separated, which is why it is the dominant style in Python, SQL, and Rust.
Related Tools
You May Also Need
You may also need
- camelCase ConverterSwitch between code naming styles
- Find and ReplaceRoll the new key through a file
Next steps
- camelCase ConverterProduce a camelCase variant for front-end code
Alternatives
- camelCase ConverterUse camelCase for JavaScript or JSON
- kebab-case ConverterUse kebab-case for URLs and CSS