snake_case Converter

Convert any text, camelCase or kebab-case into snake_case, one name per line. Perfect for Python variables, database columns and file names. Free.

snake_case writes everything in lowercase and puts an underscore between words: user_first_name, order_total, created_at. It is the standard for Python variables and functions (PEP 8 says so), Ruby, Rust and a lot of SQL, and it is the form you will see in database column names and many file names.

Type or paste a phrase, one name per line, and each comes out converted on its own line.

Why people pick it

Underscores are readable in a way that run-together words are not, and unlike hyphens they are legal in variable names in almost every programming language. That makes snake_case a safe, boring choice for names that have to work across systems. In a SQL database it also avoids a trap: many databases fold unquoted names to one case, so a column called userName quietly turns into username and loses its capital, while user_name stays readable.

What the converter does with different input

Anything that separates words counts as a break: spaces, hyphens, punctuation, and the point where a lowercase letter meets a capital. So userFirstName, User First Name and user-first-name all become user_first_name. Digits stay with the word before them, which makes version2Final into version2_final.

There are two things to be aware of. First, acronyms: HTTPResponse has no lowercase-to-capital boundary in it, so it comes out as httpresponse rather than http_response. If you type the phrase as http response you get what you want. Second, punctuation is removed completely, so “user’s name” becomes user_s_name. Clean contractions out first with remove special characters, or replace the apostrophe with a space.

Common jobs

Turning spreadsheet column headings into field names before an import: paste the header row one heading per line and take the result. Renaming a batch of files in a consistent style. Converting JSON keys from an API that uses camelCase into the names a Python or Ruby project expects. Generating constant names, for which CONSTANT_CASE puts the same thing in capitals.

If the text is destined for a URL rather than code, the slug generator is the better choice, with hyphens rather than underscores, and our short guide to SEO-friendly URLs explains why search engines prefer them. The case converter displays snake_case beside every other style if you are comparing.

Database columns and private names

In SQL, snake_case also keeps you clear of some traps. Avoid names that are reserved words such as order or group, because they must be quoted everywhere; order_total and user_group are safe. Pick singular or plural for table names and stay with it. Python adds two conventions on top of the basic style: a single leading underscore, as in _cache, marks a name as internal by agreement, and double underscores on both sides, as in __init__, are reserved for the language itself, so do not invent your own.

Frequently asked questions

Why did HTTPResponse become httpresponse?

Word breaks are found where a lowercase letter or digit is followed by a capital. HTTPResponse has none, so it is read as one word. Type it as "http response" to get http_response.

Should file names use snake_case or kebab-case?

For web pages and URLs, kebab-case is better since search engines treat hyphens as word separators. For scripts, data files and anything handled by code, snake_case is more convenient because underscores are valid in identifiers.

Does it work with non-English letters?

Yes. Accented letters and other alphabets are treated as letters and kept, lowercased. Only spaces, punctuation and symbols act as separators.