snake_case Converter

Character Count: 0 Word Count: 0 Line Count: 0
Sc

Convert Text to snake_case for Python, Ruby, and SQL

snake_case is a naming convention where words are written in lowercase and separated by underscores, for example, user_profile or calculate_total. It is the standard convention for variable and function names in Python (per PEP 8), Ruby, Rust, and Elixir, and is widely used for SQL column names, environment variables, and file names. The name comes from the way the underscores connect words along the ground like a snake.

This converter detects word boundaries in camelCase, PascalCase, kebab-case, and plain text, then joins them with underscores. Enable the SCREAMING_SNAKE_CASE checkbox for uppercase constant names like MAX_RETRIES or API_BASE_URL.

Where is snake_case the standard naming convention?

Python's PEP 8 style guide mandates snake_case for variable names, function names, method names, and module names. Ruby uses it for the same purpose. Rust uses snake_case for functions, variables, and modules (and enforces it with compiler warnings). PostgreSQL and other SQL dialects conventionally use snake_case for table and column names. It is also common in shell scripting, configuration files, and REST API field names in frameworks like Django and Rails.

What is SCREAMING_SNAKE_CASE and when should I use it?

SCREAMING_SNAKE_CASE is snake_case written entirely in uppercase, for example MAX_RETRIES or API_BASE_URL. It is the conventional format for constants in Python, C, C++, Java, JavaScript, and Rust. Environment variables also follow this convention (DATABASE_URL, NODE_ENV). Use the SCREAMING_SNAKE_CASE toggle above to convert your text to this format.

What is the difference between snake_case and kebab-case?

Both conventions use lowercase words with a separator character. snake_case uses an underscore (user_profile); kebab-case uses a hyphen (user-profile). The key difference is context: snake_case is valid in most programming languages as an identifier name, while the hyphen in kebab-case would be interpreted as a minus operator. That is why snake_case is used for code (Python variables, SQL columns) and kebab-case is used for contexts outside code (CSS properties, URL slugs, HTML attributes).

Can this convert camelCase to snake_case?

Yes. Paste getUserName and the converter will output get_user_name. It splits on camelCase word boundaries automatically and also accepts PascalCase (GetUserName), kebab-case (get-user-name), and plain text. Acronyms like XMLParser become xml_parser, and digit boundaries are detected so myVar2Name becomes my_var_2_name.