snake_case Converter — Rules, Use Cases & Examples
Updated: May 2026
snake_case is the predominant naming convention in Python, SQL and many system-level languages. Understanding its precise rules, its variant SCREAMING_SNAKE_CASE, and how it compares to kebab-case helps you make consistent choices across any codebase or project.
Free · No upload · Instant results
What is snake_case?
snake_case is a naming convention where all words are lowercased and joined by underscores. There are no spaces, no capital letters, and no other separators. The name is a visual metaphor: the underscores resemble a snake lying flat on the ground.
Typical snake_case identifiers:
user_profile— a variable or table nameget_user_name— a function name in Pythontotal_item_count— a counter variablecreated_at— a database column namemax_retry_attempts— a configuration value
The rules are simple: lowercase every letter, replace every space or punctuation boundary with an underscore, and remove everything else.
Where snake_case is the standard
snake_case is not universal — it is the dominant style in specific ecosystems.
- Python: PEP 8 mandates snake_case for all variable names, function names, method names and module (file) names. Class names use PascalCase; constants use SCREAMING_SNAKE_CASE.
- SQL: Column names, table names and stored procedure names are conventionally written in snake_case across PostgreSQL, MySQL and most SQL dialects. SQL identifiers are case-insensitive, but snake_case is unambiguous across tools and editors.
- Ruby: snake_case is idiomatic for method names and local variables. Rubocop, the Ruby linter, enforces this by default.
- Rust: The compiler issues warnings for non-snake_case variable and function names. Only types and traits use PascalCase.
- File names: snake_case is safe for file names on all operating systems because underscores are unambiguous. Spaces cause problems in shell scripts; hyphens are treated as operators in some contexts.
- REST API JSON keys: Many REST APIs (particularly those designed by Python or Ruby teams) return JSON with snake_case keys:
first_name,created_at,account_id.
snake_case vs kebab-case
Both snake_case and kebab-case use lowercase words — the only difference is the separator character. snake_case uses underscores (_); kebab-case uses hyphens (-). The choice of separator is determined by where the identifier will be used:
- In code (Python, SQL, Rust): use snake_case. Hyphens are not valid in most programming language identifiers because the parser interprets them as the subtraction operator.
- In HTML/CSS: use kebab-case. CSS class names like
btn-primaryand HTML data attributes likedata-user-idfollow this convention by specification. - In URLs: use kebab-case. Google recommends hyphens over underscores in URL paths for better SEO, as Google's crawler historically treated underscores as word-joiners rather than word-separators.
If you are building a REST API, a common pattern is to use snake_case in the backend database and JSON payloads, and kebab-case in the URL paths: GET /api/user-profiles/{user_id}.
SCREAMING_SNAKE_CASE — the constant variant
SCREAMING_SNAKE_CASE (also called CONSTANT_CASE or UPPER_SNAKE_CASE) follows the same separator rule as snake_case but uppercases every letter. It signals to the reader that an identifier is a constant — a value that never changes at runtime.
MAX_CONNECTIONS— a database pool limitAPI_BASE_URL— a configuration endpointDEFAULT_TIMEOUT_MS— a timing constantHTTP_STATUS_OK— a status code alias
In Python this is used for module-level constants. In JavaScript it is used for const values that represent fixed configuration or magic numbers. In Java and C it is the standard for static final and #define values respectively.
Frequently asked questions
What is snake_case?
snake_case writes compound words in lowercase and joins them with underscores. Example: user_profile, get_user_name, total_item_count.
What is the difference between snake_case and kebab-case?
Both use lowercase words, but snake_case separates them with underscores while kebab-case uses hyphens. snake_case is standard in Python and SQL; kebab-case is standard in CSS and URL slugs.
Should I use snake_case for Python file names?
Yes. PEP 8 recommends snake_case for module names (file names without .py). Example: my_module.py, data_loader.py.