How to convert camelCase to snake_case
Convert camelCase names to snake_case instantly. Type or paste a variable, function or column name and get the snake_case version as you type.
- Type or paste a camelCase name, such as getUserById, into the box above.
- The snake_case version appears right away: getUserById becomes get_user_by_id.
- Copy the result, or pick one of 17 naming styles for the From and To boxes.
How the conversion works
The converter first splits the name into words: at each capital letter, underscore, hyphen, dot and space. Then it writes the words in snake_case: every word lowercase, joined with underscores. Runs of capitals such as HTTP are kept together as one word, and digits stay attached to the word they follow.
camelCase to snake_case examples
| camelCase | snake_case |
|---|---|
getUserById | get_user_by_id |
firstName | first_name |
parseHTTPResponse | parse_http_response |
isValid | is_valid |
totalPriceUsd | total_price_usd |
address2Line | address2_line |
camelCase and snake_case explained
camelCase starts with a lowercase word and capitalizes every following word, with no separators. It is the standard for variables and functions in JavaScript, Java, C# and Swift.
snake_case writes every word in lowercase and joins them with underscores. It is the standard in Python and Ruby and the usual style for database column names.
Frequently asked questions
What happens to acronyms like HTTP or ID?
A run of capital letters is treated as one word, so parseHTTPResponse becomes parse_http_response in snake_case.
Does it change the meaning of my code?
No. It only rewrites the name. Remember to rename every place that uses the name, or your code will look for the old one.
Which style should I use?
Follow the convention of your language or project: camelCase in JavaScript and Java, snake_case in Python, Ruby and SQL, kebab-case in URLs and CSS.
Is this tool free?
Yes, it's free to use. No signup, no email required. Get results on this page.
How do I get my result?
Use the tool on this page. Your result appears here; no email delivery is required.