Skip to content
Developer

Case Converter

Case conventions carry meaning in code: camelCase for variables, PascalCase for classes and types, snake_case for Python and SQL columns, kebab-case for URLs and CSS, CONSTANT_CASE for constants and environment variables. Converting between them means finding the word boundaries first, which is the harder half.

By Updated Runs in your browser — nothing is uploaded

Input · text

Words are split on spaces, punctuation, underscores, hyphens and camelCase humps, so you can paste an identifier in any existing style. Everything runs in your browser.

On this page
  1. Case is a convention, and conventions carry meaning
  2. The cases, and where each belongs
  3. Two arguments worth knowing
  4. Title case has no single correct answer
  5. Case conversion is harder than it looks
  6. Environment variables are a standard, not a habit
  7. What this tool does not do

Case is a convention, and conventions carry meaning

Renaming user_account_id to userAccountId does not change what it refers to. It changes which language, which layer, and often which team you are talking to — and getting it wrong is the kind of small friction that shows up in every code review.

Most languages have settled on a house style, and in several of them the case itself is load-bearing. In JavaScript, Java and C#, a name beginning with a capital is a class or a type and a name beginning lowercase is a variable or a function. In Go, capitalisation is not a convention at all: an identifier starting with an uppercase letter is exported from its package and a lowercase one is not, enforced by the compiler.

The cases, and where each belongs

camelCaseuserAccountId. First word lowercase, every subsequent word capitalised. JavaScript and Java variables and functions, C# locals and parameters, JSON keys by convention in most web APIs.

PascalCaseUserAccountId. Also called UpperCamelCase. Classes, types, interfaces and constructors across the C family. C# uses it for public members too, which is the main way C# code looks different from Java at a glance.

snake_caseuser_account_id. Python variables and functions, Ruby methods and locals, Rust identifiers, and column names in most SQL schemas.

CONSTANT_CASEUSER_ACCOUNT_ID. Also called SCREAMING_SNAKE_CASE. Compile-time constants in nearly every language, and environment variables everywhere.

kebab-caseuser-account-id. URL slugs, CSS class names, HTML attributes, npm package names, and command-line flags. It cannot be used for identifiers in most languages, because the hyphen is the subtraction operator — which is precisely why it is safe in the places where it is used.

Train-CaseUser-Account-Id. HTTP header names, as in Content-Type and X-Request-Id. Header names are case-insensitive per the HTTP specification, but this is the conventional presentation, and HTTP/2 lowercases them on the wire.

dot.caseuser.account.id. Java package names, configuration keys, and the property paths in most config formats.

Title Case and Sentence case are editorial rather than technical, and are covered below.

Two arguments worth knowing

snake_case survives lowercasing; camelCase does not

Many SQL databases fold unquoted identifiers to a single case — PostgreSQL to lowercase, Oracle to uppercase. A column created as userAccountId becomes useraccountid, and every word boundary is gone. Created as user_account_id, it survives intact.

This is a real reason, not an aesthetic one, and it is why almost every schema you will encounter uses snake_case for columns even when the application code around it is camelCase.

kebab-case is better for URLs than snake_case

Google has stated that hyphens are treated as word separators in URLs and underscores are not. So /blue-widgets reads as two words and /blue_widgets can be read as one token. For a URL that is meant to rank for a phrase, that matters.

Case matters in URLs for a second reason: path components are case-sensitive on most web servers, so /Blue-Widgets and /blue-widgets are two different pages. Two URLs serving identical content is a duplicate-content problem you did not need to have. Lowercase everything.

Title case has no single correct answer

This surprises people who assume there is a rule. There are several, they disagree, and the disagreements are not trivial.

The common core is stable: capitalise the first and last word, capitalise all major words — nouns, pronouns, verbs, adjectives, adverbs — and leave articles, coordinating conjunctions and short prepositions lowercase in between.

The disagreement is about where "short" stops.

  • APA style capitalises words of four letters or more, including prepositions, so "With" and "From" are capitalised
  • Chicago lowercases all prepositions regardless of length, so "Through" stays lowercase
  • AP style capitalises prepositions of four letters or more, like APA, but treats some other categories differently

The word "is" is capitalised in every guide, because it is a verb, and it is the word most often got wrong — it is short, so it looks like it belongs with "in" and "of", and it does not.

This tool follows the APA rule and says so above the output. If you are writing to a house style, check it; if you are not, pick one and stay consistent, which matters more than which one you picked.

Sentence case — capitalise only the first word and any proper nouns — is now the default in most product and documentation style guides, including Google's, Apple's and the UK Government Digital Service's. It is easier to read at small sizes, easier to apply consistently, and does not require anyone to memorise a preposition rule.

Case conversion is harder than it looks

It is not a per-character operation

The German ß uppercases to SS. One character becomes two, so the string gets longer. A capital ẞ exists but is not what a default uppercase produces.

Turkish has two i's. Dotted i and dotless ı are separate letters. Uppercasing i gives İ in a Turkish locale and I everywhere else. This has broken real software: a case-insensitive comparison of the string "file" against "FILE" fails on a Turkish system, which is why security-sensitive comparisons should use locale-invariant case folding rather than toUpperCase.

Some scripts have no case at all. Chinese, Japanese, Arabic, Hebrew, Thai and Devanagari have no upper and lower forms, so case conversion is a no-op — which is correct behaviour, not a failure.

Greek final sigma. The letter ς appears only at the end of a word, and σ everywhere else. Correct lowercasing has to know where the word ends.

Unicode specifies all of this in its default case algorithms, and the short version is that changing case is a locale-sensitive string transformation and should be treated as one.

Splitting words is ambiguous

Before you can convert a case, you have to know where the words are. This tool splits on separators, punctuation, and the transition from lowercase to uppercase — the boundaries every convention recognises.

The awkward case is a run of capitals. XMLHttpRequest should split into XML, Http, Request, not into eleven single letters and not into XMLHttp and Request. The rule that gets this right is to keep a run of capitals together except for its last letter, which belongs to the word that follows.

Acronyms then raise a style question with no universal answer: is it parseHTTPResponse or parseHttpResponse? Google's Java style guide says treat acronyms as ordinary words — parseHttpResponse — on the grounds that it makes the splitting rule unambiguous. Microsoft's .NET guidelines keep two-letter acronyms uppercase and title-case longer ones. Both are defensible; consistency within a codebase is what actually matters.

Digits are another judgment call. This tool keeps a digit attached to the word before it, so version2 stays one word rather than becoming version 2, which matches how identifiers are usually read aloud.

Environment variables are a standard, not a habit

The convention of uppercase environment variable names is stronger than a convention. POSIX defines the portable character set for environment variable names as uppercase letters, digits and underscore, and reserves lowercase names for applications.

Lowercase names usually work in practice, and shells will accept them. But tooling that assumes the standard exists, and the failure when you find some of it is obscure. Use DATABASE_URL, not database_url.

What this tool does not do

It converts one block of text at a time. Bulk-renaming identifiers across a codebase is a refactoring job for an IDE or a language-aware tool, both of which understand scope and will not rename a string that happens to match.

It also cannot know your proper nouns. Sentence case lowercases everything after the first word, which is right for most sentences and wrong for any containing a name — restore those by hand.

Everything runs in your browser. Case mapping uses the platform's Unicode-aware implementation, so the ß and Greek sigma behaviour described above is the standard behaviour rather than something reimplemented here. The Unicode case algorithms, the APA title case rule and the POSIX environment variable definition are all linked below.

Common questions

Frequently asked questions

What is the difference between camelCase and PascalCase?

Only the first letter. camelCase starts lowercase and capitalises each subsequent word — userAccountId. PascalCase capitalises the first word too — UserAccountId. Most language conventions use them for different things: in JavaScript, Java and C#, variables and functions are camelCase while classes and types are PascalCase, so the case itself tells you what kind of thing a name refers to.

Which case should I use for a URL slug?

kebab-case, lowercase, with hyphens between words. Google has stated that hyphens are treated as word separators in URLs while underscores are not, so this-is-a-page reads as three words and this_is_a_page can read as one. Lowercase matters too: URL paths are case-sensitive on most servers, so two casings of the same path are two different pages as far as a crawler is concerned.

What words are not capitalised in title case?

Style guides differ, which is why there is no single correct answer. The common core is that articles (a, an, the), coordinating conjunctions (and, but, or, nor) and short prepositions stay lowercase unless they are the first or last word. Where guides diverge is the length cut-off for prepositions: APA and Chicago capitalise prepositions of four letters or more, while AP uses a threshold of four as well but differs elsewhere. This tool follows the APA-style rule and says so rather than pretending there is a universal one.

Why does uppercasing sometimes change the length of a string?

Because case mapping is not one-to-one. The German ß uppercases to SS, two characters where there was one. The Turkish dotless ı and dotted İ map differently again, and lowercasing "I" in a Turkish locale gives ı rather than i — which has broken real software that compared identifiers case-insensitively. Unicode defines all of this in its default case algorithms, and the rule to remember is that changing case is a locale-sensitive transformation, not a per-character lookup.

What is snake_case used for?

Python variables and functions, Ruby methods, SQL column names in most schemas, and Rust identifiers all use snake_case. It has one practical advantage over camelCase: it survives being lowercased. Systems that fold identifiers to lowercase — which many SQL databases do — turn userAccountId into useraccountid and lose the word boundaries entirely, whereas user_account_id comes through intact.

What is CONSTANT_CASE and when is it used?

Uppercase words separated by underscores, also called SCREAMING_SNAKE_CASE. It is the near-universal convention for compile-time constants and for environment variables. The environment variable case is more than convention: POSIX defines the portable character set for environment variable names as uppercase letters, digits and underscore, so lowercase names, while usually accepted, are outside the standard.

How does the converter split words in the first place?

It looks for the boundaries every convention uses: spaces and punctuation, underscores and hyphens, and the transition from a lowercase letter to an uppercase one. Runs of capitals are handled as a unit so that XMLHttpRequest splits into XML, Http and Request rather than into single letters. Digits are treated as attached to the word they follow, so version2 stays one word rather than becoming two.

References

Sources

The formulas and reference ranges on this page come from the following publications. Where a source has been revised, we cite the current edition.

  1. 1The Unicode Standard, Section 3.13 — Default Case AlgorithmsThe Unicode Consortium
  2. 2APA Style — Title Case and Sentence Case CapitalizationAmerican Psychological Association
  3. 3POSIX.1-2017 — Environment Variable DefinitionThe Open Group / IEEE

Keep going