Skip to main content

Text Case Conversion: camelCase, snake_case, and More

· 5 min read

Changing the case of text by hand is tedious and error-prone, especially when you are converting a variable name or retyping a heading. Knowing the standard case styles, and which tool flips between them, removes the busywork. Here is each style and where it belongs.

The writing cases

These four show up in everyday prose.

  • UPPERCASE turns every letter capital, like NOTICE. Use it sparingly for short labels, acronyms, or warnings. Whole sentences in uppercase read as shouting and slow readers down.
  • lowercase makes everything small. It is useful for tags, certain brand styles, and normalizing data before comparison.
  • Title Case capitalizes the first letter of each major word, like A Guide To Color. Headlines, book titles, and navigation labels use it. Most style guides leave short words like and, of, and the lowercase.
  • Sentence case capitalizes only the first word and any proper nouns, like A guide to color. It is the natural choice for body text, UI microcopy, and increasingly for modern headings because it reads less stiffly than Title Case.

The code cases

Programming languages each have their own conventions, and following them is not optional if you want your code to look native.

  • camelCase joins words with no spaces and capitalizes every word after the first, like userAccountId. JavaScript variables, function names, and JSON keys lean on it heavily.
  • PascalCase, also called upper camel case, capitalizes the first word too, like UserAccount. It is the standard for class names, React components, and types across most languages.
  • snake_case joins words with underscores in lowercase, like user_account_id. Python variables and functions, database column names, and many config files use it. The all-caps variant marks constants.
  • kebab-case joins words with hyphens, like user-account-id. URLs, CSS class names, HTML attributes, and command-line flags all favor it, partly because hyphens are safe in web addresses where underscores can be hidden by underlines.

Where conversions go wrong

The hard part of case conversion is not capitalizing letters; it is detecting word boundaries. To turn user_account_id into camelCase, a tool must first recognize the underscores as separators, then drop them and capitalize the following letters. Converting a sentence like my long title into kebab-case for a URL means splitting on spaces and joining with hyphens.

Acronyms add friction. Should HTMLParser become htmlParser or hTMLParser in camelCase? Different conventions disagree, so review acronym-heavy names after any automatic conversion.

Numbers and symbols are another snag. Most converters strip or relocate punctuation, so a name with a version number may not round-trip cleanly between styles. When precise output matters, convert and then eyeball the result.

Do it in one place

Rather than memorizing keyboard tricks or retyping, paste your text into a Text Case Converter and pick the target style. It handles the boundary detection for camelCase, snake_case, and kebab-case, and the capitalization rules for Title and Sentence case, in a single step. That is faster than fixing each word and far less likely to introduce a typo into a variable name.

Because the conversion happens entirely in your browser, you can safely process internal API field names, unreleased feature flags, or confidential headings without sending any of it to a server.

A simple rule of thumb

For prose, use Sentence case for body text and headings, and reserve Title Case for formal titles. For code, match the language: camelCase for JavaScript variables, PascalCase for classes and components, snake_case for Python and database fields, and kebab-case for URLs and CSS. When in doubt, look at the surrounding code and copy whatever style is already there.