Text Case Converter
Convert text between UPPERCASE, lowercase, Title Case, camelCase, snake_case, and kebab-case.
Formula
String.prototype transformation methods
Each case transformation applies specific rules: uppercase/lowercase change all letters, title case capitalizes word beginnings, camelCase and others combine case changes with whitespace handling using regex patterns.
Worked Examples
Example 1: Convert to URL Slug
Problem:Transform blog title 'My Awesome Blog Post!' into URL-friendly format.
Solution:Input: My Awesome Blog Post! Step 1: Click 'lowercase' โ my awesome blog post! Step 2: Click 'kebab-case' โ my-awesome-blog-post! (Remove special chars manually or programmatically) Final URL: /blog/my-awesome-blog-post Result: Clean, SEO-friendly URL slug
Result:my-awesome-blog-post
Example 2: Create JavaScript Variable
Problem:Convert 'user profile settings' to proper JavaScript variable name.
Solution:Input: user profile settings Click 'camelCase' Output: userProfileSettings Usage: const userProfileSettings = { theme: 'dark', notifications: true }; Follows JavaScript naming conventions.
Result:userProfileSettings
Example 3: Format Database Column
Problem:Convert 'First Name' to PostgreSQL column format.
Solution:Input: First Name Click 'snake_case' Output: first_name SQL usage: CREATE TABLE users ( id SERIAL PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50) ); Standard PostgreSQL convention.
Result:first_name
Frequently Asked Questions
What is the difference between all the text case types?
UPPERCASE: ALL CAPS. lowercase: all small. Title Case: First Letter Of Each Word Capitalized. Sentence case: First letter of sentence capitalized. camelCase: wordsJoinedNoCapsFirst. PascalCase: WordsJoinedAllCapped. snake_case: words_with_underscores. kebab-case: words-with-hyphens. Each has specific uses in programming, writing, and web development.
When should I use camelCase vs PascalCase?
camelCase (myVariableName): JavaScript/TypeScript variables and functions, JSON property names, Java variables. PascalCase (MyClassName): Class names in most languages, React components, C# methods and properties, TypeScript interfaces. Convention varies by languageโfollow your project's style guide.
What is snake_case used for?
snake_case is standard in: Python (variables, functions, modules), Ruby (methods, variables), database columns/tables, environment variables, file names (especially in Unix/Linux), and PostgreSQL identifiers. It's readable while avoiding spaces, and works in case-insensitive systems.
What is kebab-case and where is it used?
kebab-case (words-with-hyphens) is used for: URL slugs (/my-blog-post), CSS class names (.my-component), HTML attributes (data-user-id), file names in web projects, npm package names, and Lisp function names. It's URL-friendly and readable in addresses.
How does Title Case differ from Sentence case?
Title Case capitalizes the first letter of every major word: 'The Quick Brown Fox Jumps Over the Lazy Dog.' Sentence case only capitalizes the first letter of the sentence: 'The quick brown fox jumps over the lazy dog.' Some title case styles leave small words (a, an, the, of) lowercase unless first word.
What is SCREAMING_SNAKE_CASE?
SCREAMING_SNAKE_CASE (also called CONSTANT_CASE) combines uppercase with underscores: MY_CONSTANT_VALUE. It's used for: constants in most programming languages, environment variables, preprocessor macros in C/C++, and enum values. The caps signify 'do not change this value.'
How do I convert text programmatically in JavaScript?
JavaScript methods: toUpperCase(), toLowerCase() for basic conversions. For others, combine with replace() and regex: Title Case: str.toLowerCase().replace(/\b\w/g, c => c.toUpperCase()). camelCase: str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, c) => c.toUpperCase()). Or use libraries like lodash (_.camelCase, _.snakeCase).
What case should I use for file names?
Depends on context: kebab-case for web files (my-component.js), snake_case for Python modules (my_module.py), PascalCase for React components (MyComponent.jsx), lowercase for most Unix files. Avoid spaces and special characters. Be consistent within a project. Case sensitivity varies by OS (Linux is case-sensitive, Windows isn't).
Why do programmers use different cases?
Cases serve as visual conventions: distinguish between variables (camelCase) and classes (PascalCase), indicate constants (UPPER_CASE), improve readability (word boundaries without spaces), and comply with language idioms. Following conventions makes code easier to read and maintain. Most linters enforce case conventions.
How do I handle acronyms in different cases?
Conventions vary: XMLHttpRequest (caps acronym) vs XmlHttpRequest (treat as word). HTML/CSS IDs: use kebab-case (xml-http-request). Modern preference tends toward treating acronyms as words: userId not userID, HttpRequest not HTTPRequest. Check your project's style guide for consistency.
Background & Theory
Text case conventions improve code readability and follow language idioms. Each case type has specific applications in programming, writing, and web development.
Case Type Reference:
| Case | Example | Common Use |
|---|---|---|
| UPPERCASE | HELLO WORLD | Constants, headers |
| lowercase | hello world | General text, URLs |
| Title Case | Hello World | Titles, headings |
| Sentence case | Hello world | Paragraphs, UI text |
| camelCase | helloWorld | JS/Java variables |
| PascalCase | HelloWorld | Classes, React components |
| snake_case | hello_world | Python, databases |
| kebab-case | hello-world | URLs, CSS, file names |
| SCREAMING_SNAKE | HELLO_WORLD | Constants, env vars |
Language Conventions:
| Language | Variables | Functions | Classes | Constants |
|---|---|---|---|---|
| JavaScript | camelCase | camelCase | PascalCase | UPPER_SNAKE |
| Python | snake_case | snake_case | PascalCase | UPPER_SNAKE |
| Java | camelCase | camelCase | PascalCase | UPPER_SNAKE |
| Ruby | snake_case | snake_case | PascalCase | UPPER_SNAKE |
| CSS | N/A | N/A | kebab-case | -- |
Conversion Rules:
- To lowercase: Simply lowercase all
- To UPPERCASE: Simply uppercase all
- To Title Case: Capitalize first letter of each word
- To camelCase: Remove spaces, capitalize each word except first
- To snake_case: Lowercase, replace spaces with underscores
- To kebab-case: Lowercase, replace spaces with hyphens
Best Practices:
- Be consistent within a project
- Follow language conventions
- Use linters to enforce style
- Document exceptions