Skip to main content

2026-02-21

5 min

By Formatho Editorial

Case Conversion: camelCase, snake_case, and Beyond

NamingConventionsCode Style
Network infrastructure representing IP addressing and subnets

Why naming conventions exist

Every language ecosystem settled on a different default casing: camelCase in JavaScript and Java, snake_case in Python and Ruby, kebab-case in CSS classes and URLs, and PascalCase for C# types and React components. When data crosses a boundary — a JSON API consumed by a Python service, a database column rendered in a React form — you convert between these conventions constantly. Getting it wrong doesn't just look sloppy: two fields that differ only by casing can collide in case-insensitive contexts, silently overwriting each other.

The four conventions at a glance

StyleExampleTypical home
camelCaseuserNameJavaScript, Java, Swift
PascalCaseUserNameC#, TypeScript types, React components
snake_caseuser_namePython, Ruby, SQL columns, env vars
kebab-caseuser-nameCSS, URLs, file names, HTML attributes

The hard part: acronyms and digit boundaries

Mechanical conversion breaks on boundaries a human sees instantly. parseHTTPResponse should become parse_http_response — not parse_httpresponse or parse_h_t_t_p_response. The three ambiguous cases are:

  • Acronyms: userID → user_id (the ID is one word, not i_d)
  • Digits: oauth2Token → oauth2_token, and sha256Hash → sha256_hash
  • Sequential capitals: getHTTP2Client requires treating HTTP2 as a unit before splitting

A correct converter tokenises the input into words first — using upper-to-lower transitions as boundaries, keeping runs of capitals together — and only then re-joins with the target separator. Naive character-by-character splitting produces the wrong answer on every acronym.

Collisions and information loss

Note that conversion is not always reversible: already_http_response and alreadyHTTPResponse both map to already_http_response, and XMLParser vs XmlParser become identical in snake_case. If you're generating identifiers (database columns, API fields), run the conversion once, store the result, and never re-convert.

Practical workflow

Paste your identifiers into the Case Converter — it handles acronyms and digit boundaries correctly, shows all target styles at once, and processes whole lists (one identifier per line) for API-payload and schema migrations. Everything runs client-side, so propietary field names never leave your machine.

Formatho Editorial — written and maintained by the team behind formatho.com, a library of free, privacy-first developer tools that run entirely in your browser. Every guide is tested against the tools it describes. Corrections and suggestions: github.com/formatho.