Case Converter
Convert text between different case styles used in programming. Perfect for maintaining consistent naming conventions across your codebase.
📝Case Converter
All Conversions
Common Examples
Usage Guide
Case Style Guide
camelCase
First word lowercase, subsequent words capitalized. No separators.
getUserName, isActive, calculateTotal
PascalCase
All words capitalized. No separators. Also called UpperCamelCase.
UserProfile, DatabaseConnection, HttpClient
snake_case
All lowercase with underscores between words.
user_name, get_data, max_retry_count
kebab-case
All lowercase with hyphens between words.
user-profile, nav-menu, btn-primary
CONSTANT_CASE
All uppercase with underscores. Used for constants.
MAX_SIZE, API_KEY, DEFAULT_TIMEOUT
Language Conventions
JavaScript/TypeScript
- • Variables & Functions: camelCase
- • Classes & Types: PascalCase
- • Constants: CONSTANT_CASE
- • File names: kebab-case or camelCase
Python
- • Variables & Functions: snake_case
- • Classes: PascalCase
- • Constants: CONSTANT_CASE
- • Modules: snake_case
Java/C#
- • Variables & Methods: camelCase
- • Classes & Interfaces: PascalCase
- • Constants: CONSTANT_CASE
- • Packages: lowercase
Ruby
- • Variables & Methods: snake_case
- • Classes & Modules: PascalCase
- • Constants: CONSTANT_CASE
- • File names: snake_case
Common Use Cases
API Development
- • JSON keys: camelCase
- • REST endpoints: kebab-case
- • GraphQL: camelCase
- • Database: snake_case
Frontend
- • CSS classes: kebab-case
- • React components: PascalCase
- • Props & state: camelCase
- • HTML attributes: kebab-case
Configuration
- • ENV variables: CONSTANT_CASE
- • Config files: snake_case
- • Package names: kebab-case
- • CLI commands: kebab-case
How Case Conventions Work
The Logic Behind Naming Conventions
Case conventions serve a fundamental purpose in programming: making code readable by clearly delineating word boundaries without using spaces, which are restricted or have special meaning in most programming languages. Each convention emerged to solve specific readability and parsing challenges.
camelCase (also called lowerCamelCase or dromedaryCase) capitalizes the first letter of each word except the first, creating a visual "hump" pattern. The algorithm is simple: split the input into words, lowercase the first word, capitalize the first letter of subsequent words, and remove all separators. For "user account name", this produces "userAccountName".
PascalCase (UpperCamelCase) follows the same logic but capitalizes the first word too. The conversion from "user account name" yields "UserAccountName". This subtle difference carries semantic meaning in most languages—camelCase typically indicates instances or values, while PascalCase indicates types or constructors.
snake_case takes a different approach, preserving lowercase letters and inserting underscores between words. It's the most visually similar to natural language spacing and is often considered more readable by non-programmers. The transformation is straightforward: lowercase all characters and replace word boundaries with underscores, producing "user_account_name".
kebab-case (also called spinal-case or lisp-case) mirrors snake_case but uses hyphens instead of underscores. This creates "user-account-name". While hyphens aren't valid in most programming language identifiers (they're interpreted as minus operators), they're perfect for URLs, CSS classes, and file names where they improve readability and SEO.
Historical Evolution of Naming Conventions
Early programming languages like FORTRAN (1957) and COBOL (1959) were case-insensitive and often limited variable names to 6 characters, making naming conventions less important. COBOL introduced hyphen-separated words (kebab-case), which influenced its Lisp-like descendant languages.
The C programming language (1972) introduced case sensitivity and allowed underscores in identifiers, popularizing snake_case, particularly in Unix system programming. The K&R C book established conventions like lowercase for variables and UPPERCASE for preprocessor macros (what became CONSTANT_CASE).
camelCase emerged with Smalltalk in the 1970s and was popularized by the Xerox Alto computer. When Apple engineers who worked on the Alto developed the Macintosh toolbox in the 1980s, they brought camelCase conventions, which spread to Object Pascal and eventually influenced all modern object-oriented languages.
PascalCase gets its name from the Pascal programming language, though the convention predates Pascal itself. The term became standard in the 1980s-1990s when Microsoft's Pascal compilers and later the .NET Framework used PascalCase for public APIs.
Python's creator Guido van Rossum formalized snake_case in PEP 8 (Python Enhancement Proposal 8) in 2001, drawing from C conventions but rejecting camelCase to emphasize readability. This decision influenced Ruby, Rust, and many modern languages prioritizing code clarity.
The web development ecosystem created its own conventions. CSS adopted kebab-case for property names (background-color, font-size) because hyphens don't create parsing ambiguity in declaration blocks. JavaScript's DOM API converted these to camelCase (backgroundColor, fontSize) because hyphens would be interpreted as subtraction in JavaScript code.
Technical Implementation and Conversion Algorithms
Converting between case styles requires solving several challenges: identifying word boundaries, handling special characters, preserving acronyms, and dealing with already-formatted input. A robust converter follows these steps:
First, split the input into individual words. This involves detecting boundaries at capital letters (UserName → User, Name), separators like underscores or hyphens (user_name → user, name), and spaces. Regular expressions often handle this: /([A-Z][a-z]+|[a-z]+|[A-Z]+(?=[A-Z][a-z]|\b)|\d+)/g captures words across different case styles.
Second, normalize the words to lowercase. This creates a consistent base for applying the target case style. "getUserName" becomes ["get", "user", "name"].
Third, apply the target case transformation. For camelCase: lowercase the first word, capitalize the first letter of subsequent words, and join without separators. For snake_case: join all lowercase words with underscores. For PascalCase: capitalize the first letter of every word and join. For kebab-case: join lowercase words with hyphens. For CONSTANT_CASE: uppercase all words and join with underscores.
Edge cases require special handling. Acronyms like "HTTP" or "API" should ideally stay together (httpClient, not hTtPClient), requiring acronym detection logic. Numbers need preservation (base64Encode, not base64encode). Leading/trailing separators should be stripped. Some converters offer options for acronym handling—strict mode (httpClient) versus loose mode (hTTPClient).
Language-Specific Conventions and Style Guides
Different programming language communities have established distinct conventions through official style guides. JavaScript follows the Airbnb Style Guide or Google JavaScript Style Guide, both recommending camelCase for variables and functions, PascalCase for classes and constructors, and CONSTANT_CASE for immutable values. TypeScript inherits these conventions while adding PascalCase for interfaces and type aliases.
Python's PEP 8 is remarkably specific: snake_case for functions, variables, and module names; PascalCase for class names; CONSTANT_CASE for constants; and specifically permits _leading_underscore for private methods. This consistency across Python codebases makes code immediately recognizable.
Java and C# use camelCase for method parameters and local variables, but PascalCase for public methods, properties, and classes. C# specifically uses PascalCase even for public properties (while Java traditionally used get/set methods in camelCase). This creates visual distinction between public APIs and internal implementation.
Go (Golang) uses case for visibility control: PascalCase identifiers are exported (public), camelCase are package-private. This makes visibility explicit in the name itself, eliminating public/private keywords. The convention is enforced by the compiler, not just style guides.
Ruby follows snake_case for almost everything except classes (PascalCase) and constants (CONSTANT_CASE). Even file names use snake_case, creating consistency across the entire ecosystem. Rails further standardized conventions like pluralized table names (users, posts) and singular model names (User, Post).
API and Data Format Conventions
REST API design commonly uses kebab-case for URLs (/api/user-profiles, /blog-posts) because URLs are case-insensitive in the domain part and should be readable to humans. However, JSON response keys typically use camelCase (userName, createdAt) in JavaScript ecosystems or snake_case (user_name, created_at) in Python/Ruby ecosystems.
GraphQL officially recommends camelCase for field names, following JavaScript conventions since it was developed at Facebook. This creates consistency with client-side JavaScript code. Arguments and enum values also use camelCase: query getUserById(userId: ID!).
Database naming conventions vary by ecosystem. SQL databases traditionally use snake_case for table and column names (user_accounts, created_at), partly because some database systems are case-insensitive. NoSQL databases like MongoDB, being JavaScript-centric, often use camelCase. ORM layers frequently perform automatic conversion—ActiveRecord in Rails converts Ruby snake_case to SQL snake_case, while TypeORM can convert TypeScript camelCase to SQL snake_case.
Environment variables universally use CONSTANT_CASE (DATABASE_URL, API_KEY, NODE_ENV) across all platforms and languages. This convention originated from Unix shell scripts and remains standard because it clearly distinguishes environment variables from regular code variables.
Readability and Maintenance Implications
Studies on code readability show that snake_case often scores slightly higher for comprehension speed, particularly among non-native English speakers, because it most closely resembles natural spacing. However, camelCase dominates in many ecosystems due to historical adoption and ecosystem inertia.
Consistency matters more than the specific convention chosen. Mixed conventions create cognitive load—developers must remember which style applies in each context. Modern linters like ESLint, Pylint, and RuboCop enforce naming conventions automatically, catching violations during development. Prettier and similar formatters can automatically convert between conventions in some cases.
Team style guides should document convention choices explicitly. Large codebases benefit from automated conversion tools when migrating between conventions, though this requires careful testing since name changes can break string-based references, serialization formats, and external APIs. When working across language boundaries (like a Python backend with a JavaScript frontend), establish clear conversion rules for shared data structures.
FAQ
Which case convention should I use for my project?
Follow the dominant convention for your language ecosystem. JavaScript/TypeScript use camelCase for variables and PascalCase for classes. Python uses snake_case for most things. When in doubt, consult the official style guide for your language (PEP 8 for Python, Airbnb or Google style guides for JavaScript, etc.).
Can I mix different case conventions in the same project?
Yes, but only where conventions dictate. For example, using camelCase for JavaScript variables, kebab-case for CSS classes, and snake_case for database columns is standard. However, never mix conventions within the same domain (don't use both userName and user_name for JavaScript variables in the same codebase).
How should I handle acronyms in camelCase or PascalCase?
Treat acronyms as single words: write "httpClient" not "hTTPClient", and "XmlParser" not "XMLParser". This improves readability. However, very short acronyms (2 letters) like "id" in "userId" stay lowercase in camelCase. Some style guides differ, so check your team's conventions.
Why can't I use kebab-case for variable names in JavaScript?
The hyphen character (-) is the subtraction operator in JavaScript and most programming languages. Writing "user-name" would be interpreted as "user minus name", causing a syntax error. This is why kebab-case is only used in contexts where it won't be parsed as code: URLs, CSS classes, and file names.