snake_case converter

Turn phrases and other naming styles into snake_case: lowercase words joined by underscores, as used in Python, Ruby and database column names. The text is converted in your browser, so table and column names stay on your device and nothing is uploaded.

How it works

  1. Paste your text

    Type or paste the text in the left box, or open a .txt file. No text to hand? Click Example.

  2. Instant result

    The result appears as you type. Change the options and see straight away what changes.

  3. Copy or download

    Copy the result with one click, save it as a file or use it as input for a next step.

Examples

Input snake_case
customer name customer_name
InvoiceDate invoice_date
vatPercentage vat_percentage
total-amount incl vat total_amount_incl_vat

Words are found at spaces, hyphens, underscores and where lower case meets upper case. Accents are removed, apostrophes dropped and & becomes and. Every line is converted separately, so you can paste a whole list of names.

Renaming a database schema

A common job is turning the property names of an object into column names. Paste the list, one name per line, and copy the converted list back: firstName, lastName and emailAddress become first_name, last_name and email_address. Acronyms are split too, so HTMLParser becomes html_parser.

Python style

PEP 8, the Python style guide, asks for snake_case for functions, methods and variables, and CAPITALS for constants. For the constants use screaming snake case, and for class names, which are CapWords, the PascalCase option of the camelCase converter.

Other styles

For URLs and CSS classes the hyphenated kebab-case is the convention.

Frequently asked questions

Where is snake_case used?

In Python variables and functions, Ruby, Rust, and SQL column and table names. It is also common in file names and in JSON from APIs written in those languages.

How does XMLHttpRequest become snake_case?

As `xml_http_request`. The tool splits where a run of capitals meets a capital followed by lowercase, so `XMLHttpRequest parser` gives `xml_http_request_parser`.

What happens to numbers?

They stay attached to the word before them: `userId2` becomes `user_id2`. Digits at the start of a word are kept as part of it.

What is the difference between a list and a single name?

With *Convert each line separately* ticked each line gives its own name. Without it, all lines are joined into one name, such as `customer_name_xml_http_request_parser`.