Case Converter (camelCase, PascalCase, snake_case, kebab-case)
Convert text between common code naming conventions. Word boundaries are detected from spaces, underscores, hyphens, and capitalization, including acronyms. Everything runs in your browser.
The five conventions
| Convention | Example | Typically used for |
|---|---|---|
| camelCase | userAccountId | Variables and methods in Java, JavaScript, C++ |
| PascalCase | UserAccountId | Classes and types nearly everywhere, plus C# members |
| snake_case | user_account_id | Python, Ruby, Rust, SQL columns |
| kebab-case | user-account-id | URLs, CSS classes, HTML attributes, CLI flags |
| CONSTANT_CASE | USER_ACCOUNT_ID | Constants and environment variables |
The differences are conventional rather than technical. What matters is consistency within a codebase, since mixed conventions make identifiers harder to predict and search for.
How word boundaries are detected
The hard part of case conversion is deciding where one word ends and the next begins. This tool splits on:
- Explicit separators: spaces, underscores, hyphens
- Lowercase to uppercase transitions:
helloWorldsplits intohelloandWorld - Acronym boundaries:
XMLParsersplits intoXMLandParser, notX,M,L,Parser
The acronym rule is what naive implementations get wrong. Splitting on
every uppercase letter turns XMLHttpRequest into
x_m_l_http_request instead of the correct
xml_http_request. The rule is that a run of capitals belongs
together, except that the last capital starts a new word if a lowercase
letter follows it.
Accented letters such as é, ö, and ü are preserved rather than stripped, which matters for identifiers derived from non-English text.
Examples
| Input | camelCase | PascalCase | snake_case | kebab-case |
|---|---|---|---|---|
hello world | helloWorld | HelloWorld | hello_world | hello-world |
XMLHttpRequest | xmlHttpRequest | XmlHttpRequest | xml_http_request | xml-http-request |
user_id | userId | UserId | user_id | user-id |
parse-JSON-file | parseJsonFile | ParseJsonFile | parse_json_file | parse-json-file |
user2Name | user2Name | User2Name | user2_name | user2-name |
Where each convention belongs
URLs and CSS use kebab-case
URLs are case-insensitive in the host portion and conventionally lowercase
throughout, so word separation needs a visible character. Underscores are
poorly suited because they can be hidden by link underlining, which is one
reason hyphens became standard. Search engines also treat hyphens as word
separators and underscores as joiners, so blue-widgets reads as
two words while blue_widgets may read as one.
SQL prefers snake_case
SQL identifiers are case-insensitive in most databases unless quoted, so
userName and username are the same column. Since
capitalization cannot be relied upon to separate words, underscores are the
practical choice.
C# capitalizes public members
.NET convention uses PascalCase for classes, methods, and public properties, and camelCase for local variables and parameters. This differs from Java, where methods are camelCase, and is a common source of friction when porting code or consuming JSON APIs. See the JSON to C# tool for handling that mapping.
Environment variables use CONSTANT_CASE
Uppercase with underscores is near-universal for environment variables, partly by Unix convention and partly because shells treat variable names case-sensitively, so a consistent style avoids collisions with lowercase shell functions.
Frequently asked questions
What happens with numbers?
Digits attach to the preceding word, so user2Name yields the
words user2 and Name. Splitting before digits would
break identifiers like base64Encode.
What about symbols or emoji in the input?
Only letters and digits form words. Everything else acts as a separator and is dropped from the output, since no naming convention permits punctuation in identifiers.
How are acronyms handled?
XMLParser becomes XML plus Parser,
producing xml_parser rather than x_m_l_parser. Note
that PascalCase output normalizes acronyms to XmlParser, which
matches .NET conventions.
Is Title Case supported?
Not currently. The tool targets code identifier conventions rather than prose capitalization, which involves language-specific rules about which words to capitalize.
Why does kebab-case not work for variable names?
Because a hyphen is the subtraction operator in most languages, so
user-name would parse as user minus name. It is used
only where the text is not parsed as code, such as URLs, CSS, and CLI flags.
Is my input sent anywhere?
No. Conversion happens entirely in your browser.
Related tools
- JSON to C# classes, which applies PascalCase automatically
- RegEx tester, for bulk renaming with patterns
- Text diff viewer, to review renaming changes
- All developer tools