One name, nine spellings
This case converter takes whatever you paste — XMLHttpRequest, user_first_name, The Art of War
— and rewrites it as camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, Title
Case, Sentence case, lower case or UPPER CASE. There is one step behind all nine: the input is
broken into words, and every convention is then a way of gluing that list back together.
That step is the whole difficulty. Separators are easy; the boundaries hidden inside getHTTPStatus
are not.
Where each convention actually lives
The choice is rarely yours alone — the receiving side has a convention and you are matching it:
- camelCase — JavaScript and Java identifiers, and the keys of most JSON produced by those languages. Also the default for GraphQL fields.
- PascalCase — types, classes and React components in nearly every language that has them; also .NET method names, which is why C# JSON tends to arrive capitalised.
- snake_case — Python and Ruby variables, SQL columns, and the JSON of anything with a Rails or Django backend. It is also the safest choice for a filename that a shell will touch.
- SCREAMING_SNAKE_CASE — environment variables and compile-time constants, and effectively mandatory for the former: shells treat lowercase names as ordinary variables.
- kebab-case — CSS classes and custom properties, HTML attributes, npm package names, and URLs. It cannot be an identifier in most languages because the hyphen is a minus sign.
- Title Case and Sentence case — headings and interface labels, where the argument is with a style guide rather than a compiler.
The acronym problem
Naive splitters break on every capital, so XMLHttpRequest becomes x_m_l_http_request and
parseHTMLDocument becomes something no one wants to read. The fix is to treat a run of capitals as
one word, but hand the final capital to the word after it — because in XMLHttp the H starts
Http, while in exportToPDF the run reaches the end and stays whole.
Converting back is where information is lost, and it is worth saying plainly: XMLHttpRequest in and
XmlHttpRequest out. The tool knows the boundaries, not that three of those letters were an
initialism. If a codebase cares — and Microsoft's own guidance says two-letter acronyms keep both
capitals while longer ones do not — convert a copy and fix the acronym by hand.
Digits get the same treatment as a separate word: parseInt32Value splits into four, which is what
the popular libraries do and what makes the conversion reversible.
Title Case and the short words
Title Case is not a mechanical rule, which is why two tools disagree about it. The convention here is
AP style: capitalise everything except a fixed list of twenty-two short articles, conjunctions and
prepositions, and capitalise those anyway when they open or close the title. The Lord of the Rings
keeps of and the second the in lowercase; Of Mice and Men capitalises the Of because it comes
first.
Chicago style differs — it capitalises prepositions of five letters or more and has its own exceptions — so if you are writing for a publication, check which guide it follows before trusting any converter, this one included.
Multiple lines, and what not to paste
Each line is converted independently, so a column of column names or a list of feature flags comes back in the same order with blank lines intact. Nothing leaves your browser, which matters when the list you are renaming is a production schema.
Need a URL rather than an identifier? The slug generator does the kebab-case job with accent folding and length limits, which is a different problem from naming a variable. For counting rather than renaming, there is the word counter.