Programming naming conventions: camelCase, PascalCase, snake_case, and kebab-case explained
Writing clean code goes beyond just making it compile and work correctly. Readability is crucial for maintenance, collaboration, and debugging. One of the fundamental pillars of readable code is adopting consistent naming conventions for your variables, functions, classes, and files.
Since spaces are not allowed in identifiers across almost all programming languages, developers use capital letters or separators to distinguish words. The four most common conventions are camelCase, PascalCase, snake_case, and kebab-case.
Style Guides: Different languages and communities have their own established standards. Using the correct casing makes your code feel native to that language's ecosystem.
The four major casing formats
1. camelCase
The first letter of the first word is lowercase, and the first letter of each subsequent word is capitalized. There are no separators.
- Example: userFirstName, calculateTotalDuration, isActive
- Common uses: Variable and function names in JavaScript, TypeScript, Java, and C#.
2. PascalCase
Every word starts with a capital letter, including the very first word. There are no separators.
- Example: UserProfile, ImageCompressor, LocalizedLayout
- Common uses: Class names in JavaScript, TypeScript, Java, Python, and C#, as well as component names in React.
3. snake_case
All words are lowercase, and they are separated by underscores.
- Example: user_first_name, database_connection, calculate_total_duration
- Common uses: Variable and function names in Python, Ruby, Rust, and database column names.
4. kebab-case
All words are lowercase, and they are separated by hyphens (dashes).
- Example: user-first-name, case-converter, theme-provider
- Common uses: URL slugs, CSS class names, HTML attributes, and package names in npm.
Convert text formats instantly
When copying variables between database tables, class configurations, and client-side interfaces, manually rewriting names can be tedious and prone to typos. You can use our free Case Converter to switch text between uppercase, lowercase, camelCase, PascalCase, snake_case, and kebab-case instantly. All conversions happen locally in your browser.
Ready to convert casing styles? Open the Case Converter