Case converter

Transform the case of a string and choose between different formats

loading Case converter
About this tool

What is a text case converter?

A case converter rewrites the same words in a different capitalisation and word-joining style. In prose that means UPPERCASE, lowercase, Capital Case and Sentence case. In programming it means naming conventions: camelCase for JavaScript variables, PascalCase for classes, snake_case for Python and databases, kebab-case for URLs and CSS classes, CONSTANT_CASE for constants and environment variables.

Renaming by hand is tedious and error-prone: a column called first name in a spreadsheet becomes first_name in SQL, firstName in JSON and FIRST_NAME in an .env file. A heading typed in capitals by mistake has to be fixed without retyping it. This tool produces fourteen styles of your text at once, so you pick the one you need and copy it.

The formats are lowercase, UPPERCASE, camelCase, Capital Case, CONSTANT_CASE, dot.case, Header-Case, no case, param-case (kebab), PascalCase, path/case, Sentence case, snake_case and an alternating mOcKiNg cAsE. Words are split on anything that is not a letter or a digit, in any script, so Latin letters with accents, Cyrillic and Greek all work, and an existing camelCase or snake_case identifier is split into its words too. Nothing is sent to a server.

How to change the case of a text

  1. Type or paste your text in the first field. It opens with lorem ipsum dolor sit amet, so all fourteen results are visible right away.
  2. Read the results below, one row per style, and press the copy button of the one you want.
  3. To convert a list, put one item per line. Each line is converted on its own and line breaks are kept, so a column of names becomes a column of identifiers.
  4. Turn on Remove accents to strip the marks from Latin letters first (ação becomes acao). This is useful for file names, slugs and keys, and it leaves other scripts untouched.
  5. Open Choose formats to hide the styles you do not use. Your selection is remembered for next time, and a message reminds you if you deselect them all.

The word splitting is what makes the tool useful for code: getHTTPResponse is understood as get, HTTP and Response, and anything between words (spaces, _, -, ., /, brackets) is a separator.

Examples of case conversion

A phrase in the main programming styles

Input Hello World from toolbox:

StyleResult
camelCasehelloWorldFromToolbox
PascalCaseHelloWorldFromToolbox
snake_casehello_world_from_toolbox
param-casehello-world-from-toolbox
CONSTANT_CASEHELLO_WORLD_FROM_TOOLBOX
Capital CaseHello World From Toolbox

Converting between identifiers

Input getHTTPResponse gives get_http_response in snake_case, get-http-response in kebab-case and GET_HTTP_RESPONSE in constants. The acronym is treated as one word and written as Http in camelCase: getHttpResponse.

A list of column names

Input, one per line:

first name
last name
birth date

With camelCase selected the output is firstName, lastName and birthDate, one per line; with CONSTANT_CASE it is FIRST_NAME, LAST_NAME and BIRTH_DATE.

Accents and a file name

Input São Paulo é ótimo gives são_paulo_é_ótimo in snake_case. With Remove accents on, it becomes sao_paulo_e_otimo, and in kebab-case sao-paulo-e-otimo.

The mocking case

Hello World from toolbox becomes HeLlO WoRlD FrOm tOoLbOx: capitals and lowercase letters alternate over every character, including the spaces.

Common problems and how to fix them

  • Names written in Capital Case look wrong. The tool capitalises every word, so Maria da Silva becomes Maria Da Silva. Fix the small words such as da, de or of by hand afterwards.
  • Sentence case lowers every other capital. Only the first letter of the text stays capital, so my API key becomes My api key. Restore acronyms yourself.
  • A number splits the identifier oddly. version 2.0 beta in camelCase gives version_2_0Beta, because digits count as separate words. Use snake_case or kebab-case for such names, or edit the number part.
  • Accents stay in my identifier. Accents are kept by default. Turn on Remove accents if the target (a URL, a column, a file) must be plain ASCII.
  • Only one result row shows. Check Choose formats: the hidden ones are not deleted, just unticked.

Frequently asked questions

How do I convert text to uppercase or lowercase?

Paste the text and copy the UPPERCASE or lowercase row. Accented letters are converted too: São Paulo é ótimo becomes SÃO PAULO É ÓTIMO.

What is the difference between camelCase and PascalCase?

Both join words without separators and capitalise each word, but camelCase starts with a lowercase letter (userName) and PascalCase with a capital (UserName). Classes and types usually use PascalCase, variables and functions camelCase.

What is kebab-case used for?

For URLs, CSS class names and file names, because hyphens are safe in them. To build a clean URL from a title, including removing accents and punctuation, use the slugify tool.

Can I convert many lines at once?

Yes: one item per line, and each is converted separately. To clean, sort or join such a list afterwards, use the list converter.

How do I count the words or letters of a text?

The word counter shows characters, words, lines, bytes and reading time.

How to convert text case in code

JavaScript

toUpperCase and toLowerCase are built in; for camelCase split the words yourself.

const words = s => s.split(/[^\p{L}\p{N}]+/u).filter(Boolean);
const camel = s => words(s).map((w, i) => i ? w[0].toUpperCase() + w.slice(1).toLowerCase() : w.toLowerCase()).join('');
camel('user_first_name');          // 'userFirstName'
camel('Hello World from toolbox'); // 'helloWorldFromToolbox'

Python

str.upper(), lower(), title() and capitalize() cover the prose styles. For snake_case from camelCase use two regular expressions.

import re

def snake(s):
    s = re.sub(r'([A-Z]+)([A-Z][a-z])', r'\1_\2', s)
    s = re.sub(r'([a-z\d])([A-Z])', r'\1_\2', s)
    return re.sub(r'[\W_]+', '_', s).lower()

snake('getHTTPResponse')  # 'get_http_response'

Bash

echo 'Hello World from toolbox' | tr '[:upper:] ' '[:lower:]_'   # hello_world_from_toolbox
echo 'Hello' | tr '[:lower:]' '[:upper:]'                         # HELLO
Report a problem