Convert Text to Sentence case
Learn how to convert text to Sentence case where only the first letter of the sentence is capitalized. Understand sentence case for UI copy, notification messages, and content style guides.
Detailed Explanation
Converting Text to Sentence Case
Sentence case capitalizes only the first letter of the text and lowercases everything else (with exceptions for proper nouns and acronyms). It mirrors how normal English sentences are written.
Basic Conversion
Input: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Output: The quick brown fox jumps over the lazy dog
Input: convert THIS Text To Sentence Case
Output: Convert this text to sentence case
Sentence Case vs. Title Case
The key difference:
Title Case: The Quick Brown Fox Jumps Over the Lazy Dog
Sentence case: The quick brown fox jumps over the lazy dog
Title case capitalizes major words; sentence case capitalizes only the first word.
Where Sentence Case Is Used
UI Copy and Microcopy
Modern design systems (Google Material, Apple HIG) recommend sentence case for most UI elements:
Button: "Save changes" (not "Save Changes")
Tab: "Account settings" (not "Account Settings")
Menu item: "Export as PDF" (not "Export As PDF")
Tooltip: "Click to copy" (not "Click To Copy")
Error: "Invalid email address" (not "Invalid Email Address")
Notifications and Messages
"Your password has been updated"
"3 new messages in your inbox"
"File uploaded successfully"
Content and Blog Posts
Some style guides (especially for web content) prefer sentence case for headings:
"How to set up your development environment"
"10 tips for writing cleaner code"
"Understanding the JavaScript event loop"
The Proper Noun Problem
A simple sentence case algorithm cannot preserve proper nouns:
Input: "MEETING WITH ALICE IN NEW YORK"
Simple: "Meeting with alice in new york" (wrong!)
Smart: "Meeting with Alice in New York" (correct, but requires NER)
Truly smart sentence casing requires either a dictionary of proper nouns or named entity recognition (NER), which is beyond simple text transformation.
Implementation Approach
A practical sentence case converter:
- Lowercase the entire string.
- Capitalize the first character.
- Optionally capitalize the first character after sentence-ending punctuation (
.,!,?). - Preserve known acronyms (if an exception list is provided).
Edge Cases
- Empty strings return empty strings.
- Single character:
"a"→"A". - Already sentence case: passes through unchanged.
- Multiple sentences: each sentence's first word should be capitalized.
Use Case
Sentence case is recommended by Google Material Design and Apple Human Interface Guidelines for UI labels, buttons, menu items, and notification messages. It is also preferred by many web content style guides for headings and subheadings. Converting all-caps or title-cased text to sentence case ensures a modern, approachable tone in user interfaces.