Snake Case Converter
Convert any text to snake_case format. Used for Python variables, database columns, file names, and API fields.
What Is Snake Case?
Snake case (also written as snake_case) is a naming convention where words are separated by underscores and all letters are lowercase. For example, my_variable_name or user_first_name.
Snake Case vs Other Naming Conventions
- Snake case:
my_variable_name— used in Python, Ruby, databases - Camel case:
myVariableName— used in JavaScript, Java - Kebab case:
my-variable-name— used in URLs, CSS, HTML attributes - Pascal case:
MyVariableName— used in C#, React components
What Is SCREAMING_SNAKE_CASE?
SCREAMING_SNAKE_CASE (also called upper snake case or CONSTANT_CASE) uses uppercase letters with underscores between words, e.g. MAX_RETRY_COUNT or API_BASE_URL. It is the standard for constants in most programming languages including Python, Java, C, C++, JavaScript, and Rust.
| Format | Example | Usage |
|---|---|---|
| snake_case | user_first_name | Variables, functions |
| SCREAMING_SNAKE_CASE | USER_FIRST_NAME | Constants, env vars |
How to Convert camelCase to snake_case
Converting camelCase to snake_case is one of the most common text transformations developers need. The algorithm inserts an underscore before each uppercase letter and then lowercases the entire string:
myVariableName→my_variable_namegetUserById→get_user_by_idHTMLParser→html_parser
This is useful when migrating JavaScript or Java code to Python, converting JSON API responses to match Python conventions, or renaming database columns.
Snake Case in Python (PEP 8)
Python's official style guide, PEP 8, mandates snake_case for variables, functions, methods, and module names:
# Variables and functions: snake_case
user_count = 42
def calculate_total_price(items, tax_rate):
...
# Constants: SCREAMING_SNAKE_CASE
MAX_CONNECTIONS = 100
DEFAULT_TIMEOUT_SECONDS = 30
# Classes are the exception: PascalCase
class OrderProcessor:
def get_pending_orders(self): # methods: snake_case
...Converting JavaScript-style names when porting code? See our guide on converting camelCase to snake_case in Python.
Snake Case for SQL Columns and Tables
Snake_case is the dominant convention for database naming because SQL is case-insensitive by default and many databases (PostgreSQL in particular) fold unquoted identifiers to lowercase:
CREATE TABLE customer_orders (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT REFERENCES customers(customer_id),
order_date DATE NOT NULL,
total_amount NUMERIC(10, 2),
shipping_status VARCHAR(20) DEFAULT 'pending'
);Mixed-case column names like orderDate require quoting ("orderDate") in PostgreSQL forever after — snake_case avoids that trap entirely.
Where to Use Snake Case
- Python variable and function names (PEP 8 standard)
- Database table and column names (SQL convention)
- PHP variable names in many legacy and WordPress codebases
- Ruby method and variable names
- API request and response field names
- Configuration file keys
- File naming in certain frameworks
- Environment variable names (SCREAMING_SNAKE_CASE)
- Rust variable and function names
Related Tools
Convert to hyphenated format with the Kebab Case Converter. Switch between JavaScript and Python naming with the CamelCase Converter. For all formats at once, try the Case Converter Online.
Related Tools
Slug Generator
Convert text to URL slugs
URL Slug Generator
Create SEO-friendly URL slugs
Text to Slug
Transform any text into a slug
Slugify Online
Slugify text instantly online
Permalink Generator
Create clean permanent URLs
WordPress Slug Generator
Generate slugs for WordPress
Blog Slug Generator
Generate slugs for blog posts
Product Slug Generator
Generate slugs for product pages
Case Converter
Convert text to any case format
CamelCase Converter
Convert text to camelCase
Title Case Converter
Capitalize text in title case
Sentence Case Converter
Convert text to sentence case
Kebab Case Converter
Convert text to kebab-case
PascalCase Converter
Convert text to PascalCase
Alternating Case
Convert text to aLtErNaTiNg CaSe
Dot Case Converter
Convert text to dot.case
Constant Case Converter
Convert text to CONSTANT_CASE
Word Counter
Count words, characters & sentences
Lorem Ipsum Generator
Generate placeholder text
Plain Text Converter
Strip formatting, clean text
Duplicate Line Remover
Remove duplicate lines from text
Remove Empty Lines
Remove blank lines from text
Sort Lines Alphabetically
Sort text lines A-Z or Z-A
Remove Line Breaks
Join lines into one paragraph
Em Dash Remover
Replace em dashes with commas or hyphens
Invisible Character Detector
Find hidden Unicode characters with code points
URL Encoder / Decoder
Encode & decode URLs online
UTM Builder
Build campaign tracking URLs
JSON Keys to camelCase
Convert JSON keys to camelCase
JSON Keys to snake_case
Convert JSON keys to snake_case