Case converter: camelCase, snake_case and more
Paste text or identifiers and get every naming convention at once: camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case and more. Paste a list and each line is converted on its own.
How to convert text case
- Paste text or an identifier in any style:
user account ID,userAccountIdorUSER_ACCOUNT_IDall give the same words. - Read off the case you need. Every convention is listed at once, each with its own Copy button.
- Convert a list by pasting one name per line, for example a column of database fields to rename as JSON keys.
Naming conventions and where they're used
- camelCase: JavaScript and Java variables and functions, JSON keys in many APIs.
- PascalCase: classes and types in most languages, React components, C# methods.
- snake_case: Python and Ruby variables, database tables and columns, Rust functions.
- CONSTANT_CASE (screaming snake case): constants and environment variables such as
DATABASE_URL. - kebab-case: URLs and slugs, CSS classes, HTML attributes, CLI flags, npm package names.
- Train-Case: HTTP headers such as
Content-Type. COBOL-CASE is its all-caps form. - dot.case and path/case: config keys (
server.port), Java packages and file paths. - Title Case and Sentence case: headings, labels and UI text.
How words are found
Text is split at spaces, punctuation (apostrophes inside words are dropped, so don't becomes dont), _, -, . and /, at every lower-to-upper change (fooBar), and before the last capital of an acronym (HTTPResponse becomes HTTP and Response). Digits stay with the word before them, so base64Encode becomes base64_encode. Accented and non-Latin letters count as letters, so créerUnCompte becomes créer_un_compte. For a sentence, Title, Sentence, lower and UPPER case only change letters and keep your punctuation.
Changing case in code
- JavaScript: lodash
_.camelCase(s),_.snakeCase(s),_.kebabCase(s), or thechange-casepackage - Python:
re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", s)).lower()for camelCase to snake_case (acronym-safe), or theinflectionpackage - Ruby on Rails:
"user_account".camelize,"UserAccount".underscore,.dasherize - Shell:
echo "$s" | sed -E 's/([a-z0-9])([A-Z])/\1_\2/g' | tr '[:upper:]' '[:lower:]'
Questions
What is the difference between camelCase and PascalCase?
Both join words without separators and capitalize each word. camelCase starts with a lowercase letter (userId), PascalCase with an uppercase one (UserId). PascalCase is also called UpperCamelCase.
How are acronyms like ID or HTTP handled?
An all-caps run is kept as one word, so parseHTTPResponse becomes parse_http_response and userID becomes user_id. In camelCase and PascalCase the acronym is written as a normal word (parseHttpResponse), which most style guides recommend.
Can I convert many names at once?
Yes. Paste one name per line and every line is converted separately, so a list of database columns becomes a list of camelCase keys you can copy in one go.
What is kebab-case used for?
URLs, CSS class names, HTML attributes, command-line flags and package names. It is called kebab-case because the words look skewered on a stick.
What is CONSTANT_CASE?
Uppercase words joined by underscores, also called SCREAMING_SNAKE_CASE. It is used for constants and environment variables, such as MAX_RETRIES or DATABASE_URL.
Is my text sent anywhere?
No. The conversion runs in your browser and nothing is uploaded or stored.