Part of Case converters
snake_case converter: Python, SQL, and database-friendly names
Paste a column header, config key, or variable name and copy the underscored output into migrations, ORM models, or data pipelines. For JavaScript object keys, camelCase is usually preferred—use our camelCase converter when you are targeting front-end code instead of Python or SQL.
How to use this converter
- Paste a phrase, camelCase field, or Title Case column header.
- Confirm acronym segments (api_key vs a_p_i_key) match your team rules.
- Copy the token into Python, SQL migrations, or data pipeline configs.
What snake_case is (and how it differs from kebab-case)
snake_case and kebab-case both separate words, but snake_case uses underscores (_) while kebab-case uses hyphens (-). Underscores are valid in Python identifiers and most database column names; hyphens are not. URLs and CSS classes often use kebab-case because hyphens read well in paths and selectors.
CONSTANT_CASE is the shouty sibling: same underscores, but every letter is uppercase for environment variables and enum values. Pick snake_case for everyday variables and columns; reserve CONSTANT_CASE for values that should never change at runtime.
Python, data science, and scripting
PEP 8 recommends snake_case for functions, variables, and module names. When you import a spreadsheet of “First Name” and “Order Total” into pandas, renaming columns to first_name and order_total before analysis keeps notebooks readable and matches library conventions.
Django models, Flask blueprints, and pytest fixtures all look more idiomatic when field names are underscored. If you are generating code from OpenAPI or GraphQL schemas that use camelCase, run field names through this converter before committing Python stubs.
SQL tables, columns, and migrations
Many teams standardize on lowercase snake_case for table and column names to avoid quoting issues across PostgreSQL, MySQL, and SQLite. Mixed-case columns without quotes behave differently on case-sensitive engines—a single convention prevents subtle production bugs.
When you rename a legacy “UserID” column to user_id, document the change in your migration and update ORM mappings in the same pull request. This tool gives you the target spelling; your migration tool handles the ALTER TABLE.
How input is split before underscoring
The converter detects word boundaries from spaces, hyphens, dots, camelCase transitions, and existing underscores. userProfileId becomes user_profile_id; “Order Line Item” becomes order_line_item.
Multiple consecutive separators collapse to a single underscore. Leading and trailing underscores are trimmed so you get clean tokens suitable for identifiers, not decorative spacing.
Workflow tips with other Case Modify tools
Common handoffs: camelCase for JSON APIs, snake_case for warehouse tables, kebab-case for public URLs. Export a CMS field list, snake_case everything for the analytics schema, then camelCase the subset exposed to mobile clients.
Pair this page with our lowercase converter when labels arrive in ALL CAPS from legacy systems—normalize case first if you need strictly lowercase underscores throughout.
Common mistakes
Using snake_case in public URL paths where hyphens read better.
Quoting mixed-case columns in PostgreSQL without a consistent lowercase convention.
Confusing snake_case variables with SCREAMING_SNAKE_CASE constants.
Renaming a column in production without updating ORM models and downstream reports together.
Before and after examples
Review acronyms (api_key vs a_p_i_key) against your team style guide.
| Original | Converted | Notes |
|---|---|---|
| user profile id | user_profile_id | Plain phrase |
| userProfileId | user_profile_id | From camelCase |
| Order-Line-Item | order_line_item | From kebab-case |
| MAX RETRY COUNT | max_retry_count | From spaced caps |