Open tools · 0

About

snake_case Converter

Paste a phrase, a camelCase or kebab-case name, or a column of them one a line, and each comes back in snake_case, lower case with underscores: First Name becomes first_name. It is the form Python’s style guide asks for in names, and the one SQL databases keep without quoting.

What it does

  • A change of case marks a new word, so userID becomes user_id and getHTTPResponseCode becomes get_http_response_code.
  • Numbers set apart by spaces or dots stay words of their own: version 1.2 release becomes version_1_2_release.
  • CONSTANT_CASE, the same in capitals, is one choice away, for constants and environment variables.
  • Accented letters stay, so Ünlü Şarkı becomes ünlü_şarkı; the URL slug style is the one that takes accents off.
  • Hyphens, dots and spaces each become one underscore, and runs of them leave no doubles.

How to use it

  1. Paste one name a line, from code, a spreadsheet or a JSON file.
  2. Pick snake_case, or CONSTANT_CASE for constants.
  3. Copy the list.

What it does not do

  • A capital kept for an acronym: userID comes out user_id, since snake_case is lower case throughout.
  • Words run together with no change of case: firstname stays firstname, as nothing in it says where one word ends.

Questions

Why do Python and SQL use snake_case?

Python’s style guide, PEP 8, asks for lower case with underscores in function and variable names. Databases such as PostgreSQL fold unquoted names to lower case, so firstName would need quoting every time, and first_name never does.

How do I convert camelCase to snake_case?

Paste the names and pick snake_case: firstName becomes first_name, and XMLHttpRequest becomes xml_http_request. A capital after a lower-case letter starts a new word, and so does the last capital of a run.

What is CONSTANT_CASE?

Snake_case in capitals, such as MAX_RETRIES or DATABASE_URL: the form for constants in most languages, and for environment variables.

Everything here runs in your browser. Nothing you type, paste or open is uploaded, and there is no account and no queue. How that works.

Often used with

More in Text Tools

  • Word Counter: Count words, characters, sentences and paragraphs as you type, with reading time, keyword density and readability.
  • Text Compare: Compare two texts or files and see every difference, side by side or inline, word by word, with case and spaces ignored if you like.
  • Notepad: Notes kept in your browser and nowhere else, written in Markdown with a preview, locked with a password if you like, saved as .md, .html or .txt.
  • DOCX Viewer: Open a Word document in your browser, read it on its pages with its tracked changes and comments, and save it as a PDF.

All toolsAbout utilbrewPrivacy