/ developer & network toolbox
← all tools

$ snake_case

runs locally

snake_case Converter

Convert any text, camelCase or kebab-case identifier to snake_case instantly, with CONSTANT_CASE and the other cases one click away.

case-snake — invoker.tools
stats0 chars · 0 words · 0 lines

About the snake_case Converter

This snake_case converter rewrites any text as a snake_case identifier while you type: all lower case, words joined with underscores. userAccountId becomes user_account_id, Order Line Item becomes order_line_item and parseJSONResponse becomes parse_json_response. One click switches the output to CONSTANT_CASE, camelCase, kebab-case or any of the other styles.

Words are split on spaces, hyphens, punctuation and on case boundaries, so identifiers that are already camelCase or PascalCase convert correctly instead of collapsing into one long lower-case word. Acronyms are recognised as a single word: HTTPServerError becomes http_server_error.

snake_case is the standard for variables and functions in Python (PEP 8), Ruby and Rust, for column and table names in most SQL databases, and for keys in many REST APIs and configuration files. CONSTANT_CASE, its upper-case sibling, is the usual style for constants and environment variables such as DATABASE_URL.

Everything runs in your browser. The text you paste never leaves your device.

How to use it

  1. Paste or type your text, camelCase identifier or column name.
  2. Read the snake_case result, which updates live as you type.
  3. Click copy to take the result.
  4. Click CONSTANT for environment variables and constants, or any other case to switch.

Examples

  • userAccountId → user_account_id
  • OrderLineItem → order_line_item
  • parseJSONResponse → parse_json_response
  • max-retry-count → max_retry_count
  • Database URL → database_url (CONSTANT: DATABASE_URL)

Where snake_case is the convention

  • Python: variables, functions, methods and module names (PEP 8); constants in CONSTANT_CASE.
  • Ruby: variables, methods and file names.
  • Rust: variables, functions and modules; types use PascalCase.
  • SQL: table and column names in PostgreSQL, MySQL and most schema conventions.
  • Environment variables and constants in almost every language: CONSTANT_CASE.

snake_case, kebab-case and CONSTANT_CASE

All three separate words explicitly. snake_case uses underscores and lower case, which is valid in identifiers in nearly every programming language. kebab-case uses hyphens, which most languages read as a minus sign, so it is used for URLs, CSS classes, file names and command-line flags instead. CONSTANT_CASE is snake_case in capitals and signals a value that does not change.

Frequently asked questions

What is snake_case?

A naming style where words are lower case and separated by underscores, such as order_total_amount.

How do I convert camelCase to snake_case?

Paste the camelCase identifier; the converter inserts an underscore at every capital letter boundary and lowercases the result, so createdAt becomes created_at.

What happens to acronyms?

A run of capitals is one word: userID becomes user_id and HTMLParser becomes html_parser.

What is the difference between snake_case and CONSTANT_CASE?

Only the letter case. CONSTANT_CASE (also called SCREAMING_SNAKE_CASE) is upper case and is used for constants and environment variables.

Does it work on several lines at once?

The whole input is treated as one identifier. Convert one name at a time for predictable results.

More text tools