Case Converter
Switch text between camelCase,
snake_case, kebab-case, PascalCase and the rest.
Use it when names cross a boundary between conventions. For
example, a Python API sends created_at to a
JavaScript client that expects createdAt, or a SQL
schema becomes a model class. Paste a whole list and each line is
converted on its own.
1 Case Converter example
Input
2
3
4
user_first_name
getHTTPResponseCode
Order Shipped At
billing-address-line-2 camelCase
2
3
4
userFirstName
getHttpResponseCode
orderShippedAt
billingAddressLine2 2 Where each one belongs
camelCase
JavaScript and Java variables, JSON keys in most APIs, Swift properties.
PascalCase
Class names almost everywhere, React components, C# and Go exported identifiers.
snake_case
Python and Ruby variables, SQL columns, Rails and Django database schemas.
CONSTANT_CASE
Environment variables and compile-time constants, such as DATABASE_URL in a .env file.
kebab-case
CSS classes, URL slugs, HTML attributes, npm package names, CLI flags.
dot.case
Config keys in Spring and Laravel, feature flags, translation keys.
3 How the splitting works
The tool splits words on spaces, underscores, hyphens and dots,
and at the point where a lowercase letter or digit meets an
uppercase one. A run of capitals stays together as one word, so
getHTTPResponseCode comes apart as get / HTTP /
Response / Code instead of splitting every letter of HTTP.
Acronyms are treated as ordinary words. This
tool turns them into getHttpResponseCode, the form
Google's Java and JavaScript style guides recommend. If your
codebase keeps acronyms in capitals, fix those names by hand
after converting.
Each line is converted on its own, so you can paste a list of database columns, JSON keys or form fields and get the matching list back in the same order. Sentence case lowercases every word after the first, including names and acronyms, so check proper nouns in the result.
Usage
Switching identifiers between camel, snake and kebab
- 01 Paste your text into the left panel, one item per line if you are converting a list of identifiers.
- 02 Pick the target from the Case dropdown: camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case, dot.case, Title Case, Sentence case, UPPERCASE or lowercase.
- 03 The right panel updates as you type and converts each line on its own.
- 04 Click Copy Result to put the whole output on the clipboard.
Scripting
How to convert between naming cases in JavaScript, PHP and Python
JavaScript
jsconst words = (s) =>
s
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2")
.split(/[\s_\-.]+/)
.filter(Boolean);
const cap = (w) => w[0].toUpperCase() + w.slice(1).toLowerCase();
const camel = (s) => words(s).map((w, i) => (i ? cap(w) : w.toLowerCase())).join("");
const snake = (s) => words(s).map((w) => w.toLowerCase()).join("_");
const kebab = (s) => words(s).map((w) => w.toLowerCase()).join("-");
console.log(camel("get_HTTP_response")); // getHttpResponse
console.log(snake("getHTTPResponse")); // get_http_response
console.log(kebab("Order Shipped At")); // order-shipped-at The second replace stops getHTTPResponse from becoming get_h_t_t_p_response. It splits a run of capitals only before its last letter, which starts the next word.
PHP
php<?php
function toWords(string $s): array {
$s = preg_replace('/([a-z0-9])([A-Z])/', '$1 $2', $s);
$s = preg_replace('/([A-Z]+)([A-Z][a-z])/', '$1 $2', $s);
return array_values(array_filter(preg_split('/[\s_\-.]+/', $s)));
}
function camel(string $s): string {
$w = toWords($s);
return strtolower(array_shift($w)) . implode('', array_map('ucfirst', array_map('strtolower', $w)));
}
function snake(string $s): string {
return implode('_', array_map('strtolower', toWords($s)));
}
echo camel('order_shipped_at'), PHP_EOL; // orderShippedAt
echo snake('orderShippedAt'), PHP_EOL; // order_shipped_at
// Laravel ships these: Str::camel(), Str::snake(), Str::kebab(), Str::studly() Python
pythonimport re
def words(s: str) -> list[str]:
s = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", s)
s = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1 \2", s)
return [w for w in re.split(r"[\s_\-.]+", s) if w]
def camel(s: str) -> str:
parts = words(s)
return parts[0].lower() + "".join(w.capitalize() for w in parts[1:])
def snake(s: str) -> str:
return "_".join(w.lower() for w in words(s))
print(camel("order_shipped_at")) # orderShippedAt
print(snake("orderShippedAt")) # order_shipped_at
# Converting API keys on the way in and out of a dataclass is the
# most common real use for this. Gotchas
Acronym splits like parseURL vs parseUrl
- getHTTPResponse becomes get_h_t_t_p_response
- The splitter breaks between every pair of capitals. Treat a run of uppercase letters as one word by splitting only before the last capital in the run, as the examples above do.
- Numbers end up separated from their word
- Decide whether address2 is one word or two, then apply that everywhere. Splitting on a digit boundary gives address_2, and not splitting gives address2. Either choice works, but a codebase that mixes them breaks lookups that convert names automatically.
- Accented characters are dropped or mangled
- The pattern only knows ASCII letters. [a-z] and [A-Z] never match é, and \w in JavaScript is ASCII-only even with the u flag, so use \p{L} with the u flag instead. PHP needs the u modifier for UTF-8, and Python 3's re is Unicode-aware by default. For URLs, transliterate with the slug generator instead.
- The conversion is not reversible
- Often it cannot be. snake_case loses the information that HTTP was an acronym, so converting back gives Http. If both forms have to match exactly, store the original name.
Conventions
Case styles across JS, Python, SQL and URLs
Case conversion usually happens at a boundary, such as a Python or Rails API sending snake_case keys to a JavaScript client that uses camelCase. We recommend converting in one place, the serializer, instead of at every call site. Laravel, Django REST Framework and most JSON libraries have a hook for this.
Specs
Unicode case mapping specification
Questions
Case conversion questions
Which cases are covered?
Ten: camelCase, PascalCase, snake_case, CONSTANT_CASE (also called SCREAMING_SNAKE_CASE), kebab-case, dot.case, Title Case, Sentence case, UPPERCASE and lowercase.
How does it know where the words are?
It splits on spaces, underscores, hyphens and dots, and at the boundary where a lowercase letter or digit meets an uppercase one. A run of capitals stays together, so getHTTPResponse and get_http_response both come apart into the same three words.
Can I convert a whole list at once?
Yes. Each line is converted on its own, so you can paste a list of database columns or JSON keys and copy the converted list back in the same order.
What happens to numbers and symbols?
A digit stays attached to the letters before it, so address2 stays one word. A digit after a separator becomes its own word, so line-2 becomes line2 in camelCase. Punctuation that is not a separator stays where it is, which matters when the input is a sentence instead of an identifier.
Does Title Case follow a style guide?
No. It capitalizes every word. Editorial title case, as in AP or Chicago style, keeps short words like of and the in lowercase, and the rules differ between guides, so fix those words by hand.