Text Case Converter
Convert text between different case formats including camelCase, snake_case, PascalCase
Text Case Converter
Convert text between different case formats including camelCase, snake_case, PascalCase
About Text Case Converter
Convert text between different case formats used in programming, writing, and documentation. This tool supports all major naming conventions including camelCase, snake_case, PascalCase, kebab-case, and more.
- Support for 10+ case conversion formats
- Batch text processing capabilities
- Preserve special characters and numbers
- Programming language naming conventions
- Instant preview and copy functionality
How to Use Text Case Converter
- Enter Text - Type or paste the text you want to convert
- Select Case Format - Choose from camelCase, snake_case, PascalCase, etc.
- Convert Instantly - See real-time conversion as you type
- Copy Result - Click to copy converted text to clipboard
- Batch Process - Convert multiple lines at once
Advertisement
Frequently Asked Questions
What is camelCase?
camelCase is a naming convention where the first word starts with a lowercase letter and subsequent words start with uppercase letters. Example: "myVariableName". Commonly used in JavaScript, Java, and C#.
What's the difference between PascalCase and camelCase?
PascalCase (also called UpperCamelCase) capitalizes the first letter of every word, including the first word. Example: "MyVariableName". camelCase keeps the first word lowercase. Example: "myVariableName".
When should I use snake_case?
snake_case uses underscores to separate words with all letters lowercase. Example: "my_variable_name". It's the standard naming convention in Python, Ruby, and database field names.
What is kebab-case used for?
kebab-case uses hyphens to separate words with all letters lowercase. Example: "my-variable-name". Commonly used in URLs, CSS class names, HTML attributes, and file names.
How do I convert between different programming language conventions?
Different languages prefer different naming conventions. Use camelCase for JavaScript/Java, snake_case for Python/Ruby, PascalCase for C#/.NET classes, and kebab-case for CSS and URLs. This tool handles all conversions automatically.
Case Format Reference
| Format | Example | Common Usage | Languages |
|---|---|---|---|
| camelCase | myVariableName | Variables, functions | JavaScript, Java, C# |
| PascalCase | MyVariableName | Classes, types | C#, Pascal, TypeScript |
| snake_case | my_variable_name | Variables, functions | Python, Ruby, Rust |
| kebab-case | my-variable-name | URLs, CSS classes | HTML, CSS, URLs |
| UPPER_CASE | MY_VARIABLE_NAME | Constants | Most languages |
| lowercase | myvariablename | Package names | Java packages |
| UPPERCASE | MYVARIABLENAME | Macros, constants | C, C++ |
| Title Case | My Variable Name | Documentation | Markdown, docs |
Sponsored Content
Programming Language Naming Conventions
JavaScript/TypeScript:
- • Variables:
camelCase - • Functions:
camelCase - • Classes:
PascalCase - • Constants:
UPPER_CASE - • Files:
kebab-case.js
Python:
- • Variables:
snake_case - • Functions:
snake_case - • Classes:
PascalCase - • Constants:
UPPER_CASE - • Files:
snake_case.py
Java:
- • Variables:
camelCase - • Methods:
camelCase - • Classes:
PascalCase - • Constants:
UPPER_CASE - • Packages:
lowercase
C#:
- • Public members:
PascalCase - • Private fields:
_camelCase - • Local variables:
camelCase - • Constants:
PascalCase
Common Use Cases
Development:
- Variable and function naming
- API endpoint formatting
- Database column names
- Configuration file keys
- CSS class and ID names
- File and directory naming
- Environment variable names
- Code refactoring projects
Content & Documentation:
- URL slug generation
- SEO-friendly URLs
- Markdown heading formatting
- Documentation standards
- Technical writing consistency
- Data import/export formatting
- Batch text processing
- Style guide compliance
Programming Examples
JavaScript Case Converter:
class CaseConverter {
// Convert to camelCase
toCamelCase(str) {
return str.replace(/(?:^w|[A-Z]|w)/g, (word, index) => {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(/s+/g, '');
}
// Convert to PascalCase
toPascalCase(str) {
return str.replace(/(?:^w|[A-Z]|w)/g, (word) => {
return word.toUpperCase();
}).replace(/s+/g, '');
}
// Convert to snake_case
toSnakeCase(str) {
return str.replace(/W+/g, ' ')
.split(/ |B(?=[A-Z])/)
.map(word => word.toLowerCase())
.join('_');
}
// Convert to kebab-case
toKebabCase(str) {
return str.replace(/W+/g, ' ')
.split(/ |B(?=[A-Z])/)
.map(word => word.toLowerCase())
.join('-');
}
// Convert to UPPER_CASE
toUpperCase(str) {
return this.toSnakeCase(str).toUpperCase();
}
// Convert to Title Case
toTitleCase(str) {
return str.replace(/wS*/g, (txt) => {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
}
// Example usage
const converter = new CaseConverter();
const text = "Hello World Example";
console.log(converter.toCamelCase(text)); // "helloWorldExample"
console.log(converter.toPascalCase(text)); // "HelloWorldExample"
console.log(converter.toSnakeCase(text)); // "hello_world_example"
console.log(converter.toKebabCase(text)); // "hello-world-example"
console.log(converter.toUpperCase(text)); // "HELLO_WORLD_EXAMPLE"
console.log(converter.toTitleCase(text)); // "Hello World Example"
Python Implementation:
import re
class CaseConverter:
def to_camel_case(self, text):
"""Convert text to camelCase."""
components = re.split(r'[s-_]+', text.strip())
return components[0].lower() + ''.join(word.capitalize() for word in components[1:])
def to_pascal_case(self, text):
"""Convert text to PascalCase."""
components = re.split(r'[s-_]+', text.strip())
return ''.join(word.capitalize() for word in components)
def to_snake_case(self, text):
"""Convert text to snake_case."""
# Handle existing camelCase/PascalCase
text = re.sub('([a-z0-9])([A-Z])', r'\1_\2', text)
# Replace spaces and hyphens with underscores
text = re.sub(r'[s-]+', '_', text)
return text.lower()
def to_kebab_case(self, text):
"""Convert text to kebab-case."""
# Handle existing camelCase/PascalCase
text = re.sub('([a-z0-9])([A-Z])', r'\1-\2', text)
# Replace spaces and underscores with hyphens
text = re.sub(r'[s_]+', '-', text)
return text.lower()
def to_upper_case(self, text):
"""Convert text to UPPER_CASE."""
return self.to_snake_case(text).upper()
def to_title_case(self, text):
"""Convert text to Title Case."""
return ' '.join(word.capitalize() for word in re.split(r'[s-_]+', text.strip()))
def convert_all_formats(self, text):
"""Convert text to all supported formats."""
return {
'camelCase': self.to_camel_case(text),
'PascalCase': self.to_pascal_case(text),
'snake_case': self.to_snake_case(text),
'kebab-case': self.to_kebab_case(text),
'UPPER_CASE': self.to_upper_case(text),
'Title Case': self.to_title_case(text),
'lowercase': text.lower().replace(' ', ''),
'UPPERCASE': text.upper().replace(' ', '')
}
# Example usage
converter = CaseConverter()
text = "Hello World Example"
formats = converter.convert_all_formats(text)
for case_type, result in formats.items():
print(f"{case_type:12}: {result}")
Advertisement
