Developer Case

snake_case converter

What to do

Converted in your browser · nothing is uploaded

Local · avoids SQL case folding
Advertisement
320 × 100

Converts text to snake_case: everything lowercase, words joined with underscores. `User First Name` becomes `user_first_name`.

How to use the snake_case converter

1 Paste your text; the result appears as you type.
2 Pick a different conversion if you need one.
3 Copy the result.

snake_case is the convention in Python, Ruby, Rust and. Most consequentially. In SQL. The SQL reason is worth knowing because it explains a class of bug: unquoted identifiers in SQL are case-insensitive, and PostgreSQL folds them to lowercase. So a column created as firstName is really firstname, and querying SELECT "firstName" with quotes fails while SELECT firstName works and returns firstname. Using snake_case avoids the whole problem, which is why almost every database convention mandates it.

SCREAMING_SNAKE_CASE. The same thing in capitals: is the near-universal convention for constants and environment variables. Environment variables are conventionally uppercase for a historical reason that still bites: shell variable names are case-sensitive, and uppercase distinguishes exported configuration from local shell variables. A lowercase env var works but reads as a mistake to anyone else.

When converting from camelCase, the boundary is found at each capital letter, so firstName becomes first_name and parseHTTPResponse becomes parse_h_t_t_p_response, which is why the acronym advice on the camelCase page matters. Text that was written parseHttpResponse round-trips cleanly; text with a run of capitals does not.

Questions

Unquoted SQL identifiers are case-insensitive and PostgreSQL folds them to lowercase, so firstName silently becomes firstname. snake_case avoids it entirely.

MDN, StringUnicode, case mapping
Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding