snake_case Converter
Convert text to snake_case instantly. Ideal for Python, PostgreSQL, Ruby, and Rust naming conventions.
What Is snake_case?
snake_case is a naming convention where all letters are lowercase and spaces between words are replaced by underscores. The phrase “user profile picture” becomes user_profile_picture. The name is a playful reference to the way the underscores lie flat between words, like a snake on the ground.
snake_case is the dominant naming convention in several major programming ecosystems and is also the de facto standard for database column and table names. Because all characters are ASCII-safe and lowercase, it is one of the most portable identifier formats.
Where snake_case Is Used
Python (PEP 8)
Python's official style guide, PEP 8, mandates snake_case for variable names, function names, method names, module names, and package names. This is one of the most strictly followed naming rules in the Python community, and linters like Flake8 and Pylint will flag violations. Examples:
- Variables:
user_name,total_price,is_active - Functions:
get_user_by_id(),calculate_discount() - Module names:
data_processing.py,user_utils.py
The only exception in Python is constants, which use SCREAMING_SNAKE_CASE (e.g., MAX_CONNECTIONS = 100), and class names, which use PascalCase.
PostgreSQL and SQL Databases
PostgreSQL folds all unquoted identifiers to lowercase. When you write SELECT UserName FROM Accounts, PostgreSQL reads it as SELECT username FROM accounts. For this reason, the standard practice is to write all table names, column names, and index names in lowercase snake_case from the start. This avoids the need to quote identifiers everywhere and ensures compatibility with ORMs like SQLAlchemy and ActiveRecord.
- Table names:
user_accounts,order_line_items - Column names:
first_name,created_at,is_deleted - Index names:
idx_users_email,uq_orders_reference_number
Ruby and Ruby on Rails
Ruby uses snake_case for variable names, method names, and file names. Rails takes this further with strong conventions: a model named UserAccount (PascalCase for the class) maps to a table named user_accounts (snake_case, plural). Controller files are named user_accounts_controller.rb. Rails' magic depends on these naming conventions, so getting the casing right is not just a style preference — it affects whether your app works at all.
Rust
The Rust compiler enforces snake_case for variables, functions, modules, and method names. If you name a function getUserById in Rust, the compiler will emit a warning suggesting you rename it to get_user_by_id. This makes Rust one of the few languages where naming conventions are checked at compile time.
PHP and Laravel
PHP itself has inconsistent naming in the standard library, but the Laravel framework and the PHP-FIG PSR standards recommend snake_case for database columns and method parameters. Eloquent ORM models map camelCase property access to snake_case columns automatically.
snake_case vs. kebab-case
Both conventions use lowercase with a separator between words. The difference is the separator: snake_case uses underscores, while kebab-case uses hyphens. Underscores are valid in most programming language identifiers; hyphens are not (a hyphen is a subtraction operator in most languages). For code identifiers, use snake_case. For URLs, CSS classes, and file names, kebab-case is often preferred.
How to Use This snake_case Converter
Paste any text — plain English phrases, camelCase or PascalCase identifiers, or kebab-case strings — into the input box. The converter lowercases everything and joins words with underscores. Copy the result with one click.