Convert Case
Convert Case
Convert Case refers to the process of changing the capitalization style of a text string. It is a common feature in programming, text processing, and web applications to make text consistent, readable, or suitable for specific uses like URLs, class names, or user interfaces.
Why Convert Case?
-
Consistency: Ensure all text follows a uniform format.
-
Readability: Make text easier to read for users.
-
Data processing: Normalize text before saving in databases or performing searches.
-
Programming conventions: Follow coding standards, like
camelCasefor variables orStudlyCasefor classes.
Common Case Types
-
Lowercase
Converts all letters to lowercase.
Example:"Hello World"→"hello world" -
Uppercase
Converts all letters to uppercase.
Example:"Hello World"→"HELLO WORLD" -
Capitalized / Title Case
Capitalizes the first letter of each word.
Example:"hello world"→"Hello World" -
Sentence Case
Capitalizes only the first letter of the sentence; the rest is lowercase.
Example:"hELLO WORLD!"→"Hello world!" -
Camel Case
The first word is lowercase, and each following word starts with an uppercase letter. Common in variable names.
Example:"hello world"→"helloWorld" -
Studly / Pascal Case
Each word starts with an uppercase letter. Common for class names.
Example:"hello world"→"HelloWorld" -
Snake Case
Words are lowercase and separated by underscores. Common in database columns.
Example:"Hello World"→"hello_world" -
Kebab Case
Words are lowercase and separated by hyphens. Common in URLs.
Example:"Hello World"→"hello-world" -
Alternating Case
Letters alternate between lowercase and uppercase.
Example:"hello world"→"hElLo WoRlD" -
Inverse / Swap Case
Uppercase letters become lowercase, and lowercase letters become uppercase.
Example:"Hello World"→"hELLO wORLD"