- Published on
Text Case Conversion — A Developer Reference for Naming Conventions
- Authors
- Name
Every programming language, framework, and platform has its own naming convention. JavaScript uses camelCase for variables. Python uses snake_case. CSS uses kebab-case. React components use PascalCase. Database columns might use SCREAMING_SNAKE_CASE.
The challenge comes when you're working across boundaries — generating code from a schema, parsing an API response, or renaming a field across a codebase. That's where Text Case Converter saves time.
The Complete Naming Convention Reference
camelCase
First word lowercase, subsequent words capitalized. No separators.
userName createdAt getUserById isAuthenticated
Used in: JavaScript/TypeScript variables and functions, JSON keys, Java variables, Swift variables.
PascalCase (UpperCamelCase)
Every word capitalized. No separators.
UserName CreatedAt GetUserById IsAuthenticated
Used in: JavaScript/TypeScript class and component names, C# types, Java classes, Go exported names.
snake_case
All lowercase, words separated by underscores.
user_name created_at get_user_by_id is_authenticated
Used in: Python variables and functions, Ruby, SQL column names, Unix file names, Rust variables.
SCREAMING_SNAKE_CASE (UPPER_SNAKE_CASE)
All uppercase, words separated by underscores.
USER_NAME CREATED_AT MAX_RETRY_COUNT API_BASE_URL
Used in: Constants in most languages, environment variables, C/C++ macros, Python constants.
kebab-case (hyphen-case)
All lowercase, words separated by hyphens.
user-name created-at get-user-by-id is-authenticated
Used in: CSS class names and custom properties, HTML attributes, URL slugs, npm package names, YAML/JSON config keys in some systems.
dot.case
All lowercase, words separated by dots.
user.name created.at app.config.debug
Used in: Java/Kotlin package names, property files, some configuration systems.
Title Case
Each word capitalized, separated by spaces.
User Name Created At Get User By Id
Used in: Headings, button labels, navigation items, human-readable field names.
Sentence case
First word capitalized, the rest lowercase, separated by spaces.
User name Created at Get user by id
Used in: UI labels, error messages, accessibility text.
Quick Reference Table
| Convention | Example | Common uses |
|---|---|---|
| camelCase | userName | JS/TS vars, JSON |
| PascalCase | UserName | Classes, React components |
| snake_case | user_name | Python, SQL, Ruby |
| SCREAMING_SNAKE | USER_NAME | Constants, env vars |
| kebab-case | user-name | CSS, URLs, npm |
| dot.case | user.name | Java packages, configs |
| Title Case | User Name | Headings, labels |
Converting Between Cases: The Algorithm
Converting any case to another requires two steps:
- Tokenize — split the input into individual words, regardless of the source format
- Reassemble — join words in the target format
The tricky part is tokenization. A robust tokenizer must handle:
- Word boundaries from separators (
_,-,., space) - CamelCase boundaries (
userName→["user", "Name"]) - Consecutive uppercase sequences (
HTMLParser→["HTML", "Parser"]or["HTML", "Parser"])
function tokenize(input) {
return (
input
// Insert space before uppercase letters following lowercase (camel/pascal)
.replace(/([a-z])([A-Z])/g, '$1 $2')
// Insert space before sequences of uppercase followed by lowercase (HTMLParser → HTML Parser)
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
// Replace separators with space
.replace(/[-_.]+/g, ' ')
.trim()
.split(/\s+/)
.map((w) => w.toLowerCase())
)
}
Practical Use Cases
Converting API responses to local variables
REST APIs typically return snake_case JSON keys. If your codebase uses camelCase, you'll want to transform keys on ingestion:
// Convert all keys in an object from snake_case to camelCase
function keysToCamel(obj) {
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [toCamelCase(k), v]))
}
Generating code from a schema
If you're building a code generator from a database schema or OpenAPI spec, you'll need to map column names (usually snake_case) to the appropriate convention for the target language.
Renaming across a codebase
When a rename affects both JS code (camelCase) and CSS (kebab-case) and database columns (snake_case), having a fast converter to hand-check the transformations prevents typos.
Using the Text Case Converter
The Text Case Converter accepts input in any format and converts to all cases simultaneously — useful when you need the same identifier in multiple formats at once.