DevKitHub

Programming

Case Converter — camelCase, snake_case, kebab-case

Paste one name or a whole column of them and get every convention at once. Each line is converted independently, so a list of fields stays a list.

1 line

Every convention

camelCase
parseHttpResponse
PascalCase
ParseHttpResponse
snake_case
parse_http_response
kebab-case
parse-http-response
CONSTANT_CASE
PARSE_HTTP_RESPONSE
dot.case
parse.http.response
Title Case
Parse Http Response
Sentence case
Parse http response
lower case
parse http response
UPPER CASE
PARSE HTTP RESPONSE

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

Every style is produced from a single intermediate: the input is split into a list of words, then joined back with the punctuation and capitalisation that style calls for. The alternative — converting camelCase to snake_case directly — needs one rule for each pair of styles, and ten styles would mean ninety rules that slowly drift apart. Splitting once means there is exactly one place where "what counts as a word" is decided, and every style agrees with every other by construction.

The interesting part is the splitting. Underscores, hyphens, dots and spaces are obvious separators, but a capital letter is a boundary too, and a run of capitals is where most converters go wrong. parseHTTPResponse is three words, not two: the boundary is found by looking for a run of capitals followed by a capital and then a lowercase letter, which is the point where the acronym stops and the next word starts. The same rule keeps XMLHttpRequest from collapsing into one undifferentiated blob. A digit followed by a capital splits too, so utf8Encode is handled, while a trailing digit stays attached and address2 remains one word.

Lines are converted independently and the line breaks are preserved exactly, CRLF included. Pasting a column of column names out of a schema is the common case, and treating the whole block as a single sentence would fuse it into one unusable identifier. Apostrophes are kept inside words for the prose styles, so "customer's order" becomes "Customer's Order" in Title Case, and dropped for the identifier styles, because no language allows an apostrophe in a name.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

parseHTTPResponse became parseHttpResponse, not parseHTTPResponse.

Why:
Acronyms are normalised to a single leading capital. Preserving them would break round-tripping: parse_http_response contains no record of which words were acronyms, so converting back could not restore them.
Fix:
If a style guide requires screaming acronyms, fix them by hand afterwards. Google's own Java and TypeScript guides recommend the normalised form.

A whole sentence turned into one enormous identifier.

Why:
Identifier styles have no concept of a sentence — every word between separators is joined, so a paragraph becomes one name.
Fix:
Use Title Case or Sentence case for prose, or put one name per line and let each line convert separately.

The apostrophe vanished from the output.

Why:
It is removed for camelCase, snake_case and the other identifier styles, because no programming language permits an apostrophe in an identifier.
Fix:
Nothing to fix for code. The prose styles — Title, Sentence, lower and UPPER — keep it.

Frequently asked questions

Which convention should I use?
Follow the language, not a preference. JavaScript and Java use camelCase for variables and PascalCase for types; Python and Rust use snake_case; CSS and URLs use kebab-case; environment variables and constants use CONSTANT_CASE. Consistency inside a codebase matters more than the choice itself.
Can I convert a whole list at once?
Yes. Every line is converted on its own and the line breaks are preserved, so you can paste a column of database columns or JSON keys and get the same column back in the new convention.
How are acronyms handled?
An acronym is treated as one word and normalised to a single leading capital, so parseHTTPResponse becomes parseHttpResponse in camelCase and parse_http_response in snake_case. That is what makes converting back and forth lossless.

Last updated