Camel Case Converter

Convert between snake_case, camelCase, PascalCase, kebab-case, and SCREAMING_SNAKE_CASE.

Back to all tools on ToolForge

More in Text Tools



Result

About Naming Convention Converter

This converter transforms identifiers between different naming conventions used across programming languages and frameworks. Each convention has established use cases, and converting between them is essential for API integration, code migration, and cross-language development.

Naming Convention Comparison

Convention Example Primary Use Cases
camelCase userName JavaScript/Java/C# variables, functions, JSON properties
PascalCase UserName Class names, interfaces, React components, TypeScript types
snake_case user_name Python/Ruby variables, SQL columns, environment variables
kebab-case user-name HTML attributes, CSS classes, URL slugs, config keys
SCREAMING_SNAKE USER_NAME Constants, macros, environment variable names
SCREAMING-KEBAB USER-NAME Rare; some CLI flags, legacy systems

Conversion Examples

Input          → camelCase     → PascalCase    → snake_case    → kebab-case    → SCREAMING_SNAKE
-------------------------------------------------------------------------------------------------
user_name      → userName      → UserName      → user_name     → user-name     → USER_NAME
userName       → userName      → UserName      → user_name     → user-name     → USER_NAME
UserName       → userName      → UserName      → user_name     → user-name     → USER_NAME
user-name      → userName      → UserName      → user_name     → user-name     → USER_NAME
USER_NAME      → userName      → UserName      → user_name     → user-name     → USER_NAME
get_user_data  → getUserData   → GetUserData   → get_user_data → get-user-data → GET_USER_DATA
HTTPResponse   → httpResponse  → HttpResponse  → http_response → http-response → HTTP_RESPONSE
firstName      → firstName     → FirstName     → first_name    → first-name    → FIRST_NAME

Language Naming Conventions Guide

Language Variables Functions Classes/Types Constants Private
JavaScript camelCase camelCase PascalCase UPPER_CASE _camelCase
TypeScript camelCase camelCase PascalCase UPPER_CASE #camelCase
Python snake_case snake_case PascalCase UPPER_CASE _snake_case
Java camelCase camelCase PascalCase UPPER_CASE camelCase
C# camelCase PascalCase PascalCase PascalCase _camelCase
Ruby snake_case snake_case PascalCase UPPER_CASE _snake_case
Go camelCase camelCase PascalCase PascalCase lowercase
Rust snake_case snake_case PascalCase UPPER_CASE _snake_case
PHP camelCase camelCase PascalCase UPPER_CASE $camelCase

Conversion Algorithms

snake_case to camelCase:

1. Split by underscore: "user_name" → ["user", "name"]
2. Keep first word lowercase
3. Capitalize first letter of remaining words
4. Join together: "user" + "Name" = "userName"

JavaScript:
  str.replace(/_([a-z])/g, (m, c) => c.toUpperCase())

Python:
  parts = s.split('_')
  return parts[0] + ''.join(w.capitalize() for w in parts[1:])

camelCase to snake_case:

1. Find each uppercase letter
2. Insert underscore before it
3. Convert entire string to lowercase

JavaScript:
  str.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, '')

Python:
  import re
  return re.sub(r'(?

Handling acronyms:

Input: "HTTPResponse"

Simple approach (treat as single word):
  snake_case: "httpresponse" (loses readability)

Preferred approach (preserve acronym boundaries):
  snake_case: "http_response"
  camelCase: "httpResponse"

Regex for acronym handling:
  str.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
      .replace(/([a-z])([A-Z])/g, '$1_$2')
      .toLowerCase()

Common Use Cases

  • API Integration: Convert between backend (snake_case) and frontend (camelCase) naming conventions
  • Database Mapping: SQL columns (snake_case) to application properties (camelCase) in ORM models
  • Code Migration: Adapting codebases when switching languages or adopting new style guides
  • JSON Standardization: Ensuring consistent key naming across microservices and APIs
  • Cross-language Projects: Maintaining convention consistency in polyglot repositories
  • Environment Variables: Converting config keys to SCREAMING_SNAKE_CASE for deployment
  • CSS/HTML: Converting JavaScript camelCase to kebab-case for styles and attributes

Edge Cases and Special Handling

  • Leading/trailing separators: Strip before conversion (_user_name → userName)
  • Multiple consecutive separators: Treat as single (user__name → userName)
  • Numbers in names: Preserve position (user123Name → user_123_name)
  • All caps input: Treat as SCREAMING_SNAKE (USER → user, USER_NAME → user_name)
  • Mixed separators: Handle user-name and user_name identically

How to Convert Naming Conventions

  1. Enter identifier: Type or paste the variable name, function name, or text to convert.
  2. Choose target format: Click the button for your desired naming convention.
  3. View result: The converted name appears in the result box.
  4. Copy output: Click "Copy Result" to use the converted name in your code.

Tips

Frequently Asked Questions

What is camelCase and when is it used?
camelCase (lowerCamelCase) starts with a lowercase letter, then capitalizes the first letter of each subsequent word (e.g., userName, totalCount, calculateTotal). It is the standard naming convention for variables and functions in JavaScript, Java, C#, C++, Go, and PHP. JSON APIs typically use camelCase for property names.
What is snake_case and when is it used?
snake_case uses all lowercase letters with underscores separating words (e.g., user_name, total_count, calculate_total). It is common in Python (variables, functions), Ruby, SQL (table and column names), environment variables, and configuration files. Many developers prefer snake_case for readability, especially in longer names.
What is the difference between camelCase and PascalCase?
Both capitalize each word after the first. The difference: camelCase starts lowercase (userName), PascalCase starts uppercase (UserName). PascalCase (also called UpperCamelCase) is used for class names, interfaces, and component names in most languages. React components always use PascalCase.
What is kebab-case and where is it used?
kebab-case uses lowercase letters with hyphens between words (e.g., user-name, total-count). It is standard for HTML attributes (data-user-id, aria-label), CSS class names, URL slugs, configuration file keys, and command-line flags. Hyphens are not valid in most programming language identifiers.
How do I handle acronyms in naming conventions?
Acronym handling varies by style guide. Options: treat as single word (parseXml, parse_xml), treat each letter as word (parseXML, parse_xml), or lowercase entirely (parsexml). Consistency within a codebase matters more than the specific choice. Common practice: camelCase preserves acronym case (getHTTPResponse), snake_case lowercases (get_http_response).
How do I convert JSON keys between naming conventions?
For single keys, use this tool. For bulk conversion in JavaScript: use Object.keys().map() with regex replacement, or libraries like camelcase-keys (snake_case to camelCase) or snakecase-keys (reverse). Example: const camelKeys = obj => Object.fromEntries(Object.entries(obj).map(([k, v]) => [k.replace(/_([a-z])/g, (m, c) => c.toUpperCase()), v]));