Text Case Converter Guide: Convert Text Between Cases
Text Case Converter Guide: Convert Text Between Cases
A text case converter rewrites the capitalization and word separators of a string
so it fits a specific naming convention. Developers reach for it constantly:
turning a human phrase into a camelCase variable, a snake_case database
column, or a kebab-case CSS class. Try it instantly with our
Text Case Converter — it runs entirely in your browser, so
your text never leaves the page.
This guide explains what each conversion does, why case matters, the exact rules our tool applies, real tested outputs, runnable JavaScript and Python code, and the quirks you should know before you trust it in a pipeline.
What Is a Text Case Converter?
A case converter takes one input string and produces one output string in a different casing convention. Ours supports seven modes, each triggered by a single button:
- UPPERCASE — every letter capitalized.
- lowercase — every letter lowercased.
- Title Case — the first letter of each word capitalized.
- Sentence case — only the first letter of the string and the first letter after a period, exclamation mark, or question mark capitalized.
- camelCase — words joined with no spaces; every word after the first starts with a capital; the very first character is lowercased.
- snake_case — words joined with underscores, everything lowercased.
- kebab-case — words joined with hyphens, everything lowercased.
The tool is stateless: paste text, click a mode, copy the result. There is no configuration, which is exactly what makes it useful for quick ad-hoc edits.
Why Convert Text Case?
Case is not cosmetic. Different ecosystems enforce different conventions, and mismatches cause real bugs:
- Programming identifiers — JavaScript and Java favor
camelCase; Python, Rust, and SQL schemas favorsnake_case; CSS and HTML attributes favorkebab-case. - API contracts — a backend that expects
user_emailwill rejectuserEmaileven though a human reads them as the same field. - File and URL names — lower, hyphenated names are safer in URLs and filesystems. Our Slugify tool builds on the same idea for full titles.
- Documentation and UI copy — consistent Title Case headings look professional and are easier to scan.
Manually retyping a 40-character identifier is error-prone. A converter does it deterministically in one click.
Supported Case Formats at a Glance
| Mode | hello world becomes |
|---|---|
| UPPERCASE | HELLO WORLD |
| lowercase | hello world |
| Title Case | Hello World |
| Sentence case | Hello world |
| camelCase | helloWorld |
| snake_case | hello_world |
| kebab-case | hello-world |
How the Conversions Work
Under the hood the converter is a small set of regular expressions — no AI, no network, no ambiguity. The three "structural" modes (camel, snake, kebab) follow the same two-step pattern:
- Insert a separator between a lowercase letter and the uppercase letter that
follows it (
aB→a_B). This splits existingcamelCaseandPascalCase. - Replace runs of whitespace/hyphens (or underscores, depending on the target) with the target separator, then lowercase the whole string.
Title Case and Sentence case are word-based: they locate word boundaries and capitalize the leading character while lowercasing everything else.
Hands-on: Tested with the Tool
I ran real inputs through the converter and recorded the exact outputs below. These are not estimates — they are what the tool produced, and I re-implemented its logic in Node to confirm each value is reproducible.
Structural conversions
| Input | camelCase | snake_case | kebab-case |
|---|---|---|---|
hello world | helloWorld | hello_world | hello-world |
user_email_address | userEmailAddress | user_email_address | user-email-address |
getUserById | getUserById | get_user_by_id | get-user-by-id |
background-color | backgroundColor | background_color | background-color |
Letter-case conversions on hello world
- UPPERCASE →
HELLO WORLD - lowercase →
hello world - Title Case →
Hello World - Sentence case →
Hello world
Quirks I observed while testing
Being honest about edge cases matters more than a clean demo:
- Title Case does not split on
_or-.user_email_addressbecomesUser_email_addressandbackground-colorbecomesBackground-color— the underscore/hyphen is treated as part of the "word," so only the first letter is capitalized. If you wantUser Email Address, convert to spaces first. - camelCase preserves internal capitals.
USER EMAIL ADDRESSbecomesuSEREMAILADDRESS— every letter except the first stays upper, because the converter only lowercases the leading character. Feed it lower-or-space separated text for the textbook result. - Leading and trailing separators are not trimmed. Input
leading spacesyields snake_leading_spacesand kebab-leading-spaces. Strip padding before converting if you need clean output. - Punctuation rides along.
Hello, World!→ camelCasehelloWorld!and snakehello,_world!. The converter targets alphanumerics; stray punctuation is left where it lands.
Code Examples
JavaScript
These mirror the converter's actual functions, so you can drop them into a build step:
function toCamelCase(text) {
return text
.replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase())
.replace(/^[A-Z]/, (c) => c.toLowerCase());
}
function toSnakeCase(text) {
return text
.replace(/([a-z])([A-Z])/g, "$1_$2")
.replace(/[\s-]+/g, "_")
.toLowerCase();
}
function toKebabCase(text) {
return text
.replace(/([a-z])([A-Z])/g, "$1-$2")
.replace(/[\s_]+/g, "-")
.toLowerCase();
}
console.log(toCamelCase("hello world")); // "helloWorld"
console.log(toSnakeCase("getUserById")); // "get_user_by_id"
console.log(toKebabCase("background-color")); // "background-color"
Python
A faithful equivalent using the standard library:
import re
def to_camel(text):
s = re.sub(r'[^a-zA-Z0-9]+(.)', lambda m: m.group(1).upper(), text)
return re.sub(r'^[A-Z]', lambda m: m.group(0).lower(), s)
def to_snake(text):
s = re.sub(r'([a-z])([A-Z])', r'\1_\2', text)
s = re.sub(r'[\s-]+', '_', s)
return s.lower()
def to_kebab(text):
s = re.sub(r'([a-z])([A-Z])', r'\1-\2', text)
s = re.sub(r'[\s_]+', '-', s)
return s.lower()
print(to_camel("hello world")) # helloWorld
print(to_snake("getUserById")) # get_user_by_id
print(to_kebab("background-color")) # background-color
I ran both snippets; the Python output matches the JavaScript output above character for character on these inputs.
Common Mistakes
- Assuming Title Case splits on underscores. It does not — see the quirk above. Use spaces or a structural mode first.
- Expecting auto-trimming. The tool does not strip leading/trailing separators; do that yourself if the result feeds a strict parser.
- Feeding ALL-CAPS to camelCase. You get one lowercased first letter and the
rest untouched, not a clean
camelCaseword. - Hand-rolling regex in a hot path. A one-off rename is fine in a tool; for thousands of rows, reuse a single tested function (like the ones above) instead of reinventing it per file.
Related Tools
- Convert phrases into URL-safe names with the Slugify tool.
- Count characters, words, and lines with the Character Counter.
- Sort, dedupe, and filter lines with Line Utilities.
- Find and replace across text with the String Replacer.
- Read the deeper walkthrough in our Slugify Guide.
When to Use This Tool Instead of Code
You can paste a regex into a script, but for a one-off rename in a logs view, a seed file, or a design doc, the converter is faster: no project, no dependency, no copy of potentially sensitive strings to a server. For production code, keep the small functions above in your codebase; for ad-hoc edits, the browser tool wins on speed and zero setup.