How to convert to snake_case
- Paste your words or names into the top box, one per line.
- Each line is converted to snake_case in the result box.
- Copy the list and paste it into your code, SQL script or spreadsheet.
Examples
| Input | snake_case |
|---|---|
| First Name | first_name |
| userAccountId | user_account_id |
| Total Price (incl. tax) | total_price_incl_tax |
| shipping-method | shipping_method |
Where snake_case is used
- Python: PEP 8, the official style guide, uses snake_case for variables, functions and module names.
- Ruby and Rust: methods, variables and file names.
- Databases: table and column names in PostgreSQL and MySQL are very often snake_case, because unquoted names are not case sensitive.
- PHP and WordPress: WordPress functions and hooks follow it, like
get_the_title. - File names: underscores avoid problems that spaces can cause in scripts and command lines.
Turning spreadsheet headers into column names
Here is a common job: you have a spreadsheet with headers like "Customer Name", "Order Date" and "Amount Paid" and you need to import it into a database. Copy the header row, paste it into a text editor so each header is on its own line, then paste that here. You will get customer_name, order_date and amount_paid ready to use.