Skip to main content

snake_case Converter

snake_case writes a name in lowercase letters with an underscore between words, as in user_account_id. This converter turns plain words or names in another case, such as camelCase or kebab-case, into snake_case, splitting acronyms and dropping punctuation, with one name per line of input.

Universal Text Transformer

Skip to text input
Try an example:

Input

0/100,000characters0lines

Type or paste text. The output updates as you type.

Output

The converted text appears here as you type.

Words
0
Characters
0
Without spaces
0
Lines
0
Sentences
0
Reading time
0 sec

Each line is converted as its own title, so you can paste a list of headlines.

snake_case Converter examples

CaseInputOutput
From camelCaseuserAccountIduser_account_id
PunctuationTotal Price (USD)total_price_usd
AcronymXMLHttpRequestxml_http_request
Numbersutf8 encodeutf8_encode
From kebab-casebackground-colorbackground_color
One name per linecreated at updated atcreated_at updated_at

snake_case Converter rules

  1. Every letter is lowercase, and words are joined with one underscore.
  2. Each line becomes one name, so you can convert a list in one pass. Blank lines are kept.
  3. Spaces, punctuation, symbols, emoji, and the separators of other cases (_ - . /) split words and are removed.
  4. A new word also starts where a lowercase letter or digit meets a capital (getUser is get and User) and at the end of a run of capitals (XMLHttp is XML and Http).
  5. Digits stay with the letters before them, so utf8 and h264 stay whole words. In a name written in capitals, a capital after a digit does not start a new word, so 2FA, MP3, and IPV6 stay whole words.
  6. Acronyms are treated as ordinary words (HTML becomes html or Html), so their capitals are not kept.
  7. An apostrophe inside a word is dropped (don't becomes dont). Accented letters and other alphabets are kept.

How snake_case differs from camelCase

snake_case separates words with underscores and keeps every letter lowercase (user_account_id), while camelCase drops the separators and capitalizes each word after the first (userAccountId). Try the same text in the camelCase Converter.

Full comparison with examples: camelCase vs snake_case: Which Naming Convention Should You Use?

How to use

  1. 1

    Type or paste your words, or names in another case, into the editor. Put each name on its own line.

  2. 2

    The snake_case version appears in the output as you type.

  3. 3

    Copy the result into your code, configuration, or file name.

That's it! Your text is transformed and ready to use.

Three simple steps to use snake_case Converter

When to use snake_case Converter

  • Python

    Function, variable, and module names, which PEP 8 writes in lowercase with underscores.

  • Ruby and Rust

    Method, function, and variable names, which both languages write in snake_case.

  • Databases

    Table and column names. Lowercase names with underscores avoid the quoting that mixed-case names need in some databases.

FAQ

What is the difference between snake_case and CONSTANT_CASE?

Both join words with underscores. snake_case is all lowercase (max_retries), and CONSTANT_CASE is all capitals (MAX_RETRIES).

How do I convert camelCase to snake_case?

Paste the camelCase names into the editor, one per line. A new word starts at each capital letter, so userAccountId becomes user_account_id.

Why are leading underscores removed?

Underscores are treated as separators, so _private and __init__ lose them. Add them back by hand where a leading underscore has a meaning in your language.

Can I convert many names at once?

Yes. Put each name on its own line. Every line converts to one name, and blank lines stay where they are.

Is my text uploaded anywhere?

The conversion runs in your browser, so your text is not uploaded to a server to be converted.