camelCase to snake_case converter
Paste camelCase variable or field names and get them back in snake_case, ready for Python code or database column names.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter camelcase names (one per line or inside text).
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
Each camelCase name is split into words at every change from a lowercase letter or digit to a capital, and before the last capital of an acronym that is followed by a lowercase letter. The words are then lowercased and joined with underscores (_). Symbols and spaces around the names are left as they are. Example: userFirstName becomes user_first_name.
Example
Result: snake_case result: user_first_name order_total_amount parse_html_string; Names processed: 3.
userFirstName orderTotalAmount parseHTMLString
user_first_name order_total_amount parse_html_string
Limits and caveats
- Every word in the pasted text is converted, including keywords and library names, so review the result before pasting it into code.
- Digits stay attached to the letters before them, so item2Count is read as item2 and Count.
- Converting back may not restore the original exactly: an acronym such as HTML comes back as Html.
Questions about this tool
When do I need camelCase to snake_case?
When moving names from JavaScript or JSON into Python or SQL. PEP 8 recommends snake_case for Python function and variable names, and many databases name columns this way.
How are acronyms such as HTML and ID handled?
An acronym is treated as one word, so parseHTMLString becomes parse_html_string and userID becomes user_id.
Can I paste a whole line of code?
Yes. Only the names change; symbols, spaces and punctuation stay as typed, so getItemCount(userID) becomes get_item_count(user_id).
