Skip to content
cliplimeClipLime

Convert text to snake_case

Lower case words joined by underscores, one line at a time.

0 characters, 0 lines

Options

Only the letter i is affected. Turkish and Azerbaijani pair i with İ and ı with I.

Words are split at spaces, punctuation, underscores and hyphens, and where a lower case letter meets a capital (fooBar becomes foo and Bar). Each line is converted on its own, and apostrophes are dropped.

The same text in every style

Add some text to see all 12 styles side by side. The previews use the first line.

Your text stays in your browser. Nothing you type or paste is sent anywhere.

At a glance

What it does
Writes lower case words joined by underscores: user_first_name.
Input
Plain words, camelCase, PascalCase, kebab-case or text that is already snake_case.
Numbers
Stay attached to the word before them: getHTTPResponseCode2 becomes get_http_response_code2.
Apostrophes
Dropped, so 'it's ready' becomes its_ready.
Lists
Each line is converted on its own, so a column of headers becomes a column of identifiers.
Loud version
Pick CONSTANT_CASE in the style row for UPPER_SNAKE_CASE, used for constants.
Privacy
Runs in your browser. Your text is never uploaded.

How to do it

  1. 1

    Paste your names

    Type a phrase, or paste names in any style, one per line.

  2. 2

    Check the output

    snake_case is already selected, with every word in lower case.

  3. 3

    Check non-ASCII letters

    Accented letters are kept. If your database or language does not allow them, replace them first.

  4. 4

    Copy

    Press Copy, or take a different style from the table at the bottom.

Where snake_case is used

  • Python: PEP 8 asks for lower case words with underscores for functions, variables and module names.
  • Ruby and Rust: methods, variables and functions are written this way.
  • SQL: table and column names are commonly snake_case, since unquoted SQL names are not reliably case sensitive and underscores keep several words readable.
  • C and C++ standard libraries, and many APIs whose JSON keys follow a Python or Ruby back end.
  • File names and command line options that avoid spaces and capitals.

Underscores work in the names of variables in nearly every language, while hyphens do not, because a hyphen reads as a minus sign. That is why kebab-case is for URLs and CSS, and snake_case is for code and data.

snake_case, kebab-case and CONSTANT_CASE

All three split words the same way and differ in the separator and the capitals. snake_case uses underscores and small letters. kebab-case uses hyphens and small letters, which suits web addresses and CSS. CONSTANT_CASE, also called UPPER_SNAKE_CASE, uses underscores and capitals, which suits constants and environment variables. Switch between them in the style row above, or read the whole set in the table at the bottom of the tool.

Naming database columns

Paste the header row of a spreadsheet, one header per line, and you get column names: 'First Name', 'Date of Birth' and 'Postal Code' become first_name, date_of_birth and postal_code. Before you use them, check three things:

  • Length. PostgreSQL keeps only the first 63 bytes of an identifier and MySQL allows 64 characters.
  • Reserved words. A column called order or group needs quoting in most databases. Rename it, for example to order_total.
  • Non-ASCII letters. Accented letters are kept as typed. Some databases and languages accept them and some do not, so transliterate first if yours does not.

How words are split

  • XMLHttpRequest becomes xml_http_request. A run of capitals stays together until the capital that starts the next word.
  • userID becomes user_id, and version2Beta becomes version2_beta.
  • 'Hello, World!' becomes hello_world. Punctuation and spaces are separators, and doubled separators collapse into one underscore.
  • already_snake_case stays as it is, and kebab-case-input becomes kebab_case_input.

Questions people ask

What is snake_case?

A way of writing several words as one name, in lower case, with an underscore between the words: user_first_name. It looks like a snake lying along the ground.

How do I convert camelCase to snake_case?

Paste the camelCase name and keep snake_case selected. Each capital marks the start of a new word, so getUserName becomes get_user_name.

Is snake_case the same as kebab-case?

They split words the same way. snake_case joins them with underscores and kebab-case with hyphens. Pick kebab-case in the style row for URLs and CSS classes.

Does it work for Python variable names?

Yes, it produces the lower case style that PEP 8 recommends for variables and functions. It does not check that the name is valid, for example that it does not start with a digit or clash with a reserved word.

What happens to apostrophes and symbols?

Apostrophes are removed, so it's becomes its. Other punctuation and symbols count as separators and disappear, with one underscore left in their place.

Can I convert a whole list at once?

Yes. Paste one name per line and every line is converted separately. Nothing is uploaded.

Guides that help

All Text guides →