Invert Case

Swap uppercase and lowercase: Hello World → hELLO wORLD.

Back to all tools on ToolForge

More in Text Tools

Input



Result

About Invert Case

The Invert Case tool swaps uppercase letters to lowercase and lowercase to uppercase, transforming "Hello World" into "hELLO wORLD". This case transformation is useful for fixing capitalization errors, creating stylistic text effects, normalizing inconsistent data, and debugging case-sensitive issues.

Also known as "toggle case" or "swap case", this transformation is distinct from uppercase (all caps) or lowercase (all small) conversions. It preserves the character positions while inverting their case state.

Case Transformation Types

TypeInputOutputUse Case
Invert/ToggleHello WorldhELLO wORLDSwap existing case
UppercaseHello WorldHELLO WORLDEmphasis, acronyms
LowercaseHello Worldhello worldNormalization, emails
Title Casehello worldHello WorldHeadings, names
Sentence caseHELLO WORLDHello worldRegular prose

Character Handling Rules

Character TypeExamplesInvert Case Result
Uppercase lettersA-ZConverted to lowercase (a-z)
Lowercase lettersa-zConverted to uppercase (A-Z)
Digits0-9Unchanged
Punctuation. , ! ? ; :Unchanged
Symbols@ # $ % & *Unchanged
WhitespaceSpace, tab, newlineUnchanged
Accented lettersé, ñ, ü, É, Ñ, ÜCase swapped (browser dependent)

Examples

Basic examples:
  Hello World        → hELLO wORLD
  ABC xyz            → abc XYZ
  The Quick Brown Fox → tHE qUICK bROWN fOX
  a1B2c3             → A1b2C3

Mixed content (letters affected, rest unchanged):
  Email: [email protected] → eMAIL: [email protected]
  Price: $99.99 USD      → pRICE: $99.99 usd
  Path: /Home/User/docs   → pATH: /hOME/uSER/DOCS

Code snippets:
  function myFunction()  → FUNCTION MYfUNCTION()
  const API_KEY = "abc"  → CONST api_key = "ABC"
  <div class="nav">     → <DIV CLASS="NAV">

Common Use Cases

Case Inversion in Programming

JavaScript:
  function invertCase(str) {
    return str.split('').map(c => {
      return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
    }).join('');
  }

Python:
  text = "Hello World"
  inverted = text.swapcase()
  # Result: "hELLO wORLD"

PHP:
  $text = "Hello World";
  $inverted = strtr($text,
    'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');

Java:
  StringBuilder result = new StringBuilder();
  for (char c : text.toCharArray()) {
    if (Character.isUpperCase(c)) {
      result.append(Character.toLowerCase(c));
    } else {
      result.append(Character.toUpperCase(c));
    }
  }

Unicode and International Characters

Modern JavaScript engines support Unicode case conversion:

Note: Some locale-specific cases (like Turkish dotted I) may require special handling in production code.

Technical Notes

How to Invert Case

  1. Enter your text: Type or paste the text you want to transform.
  2. Click Invert Case: The tool swaps uppercase to lowercase and vice versa.
  3. Review the result: Check that the transformation looks correct.
  4. Copy the output: Use the inverted text in your document or application.

Tips

Frequently Asked Questions

What is case inversion and when is it useful?
Case inversion (also called toggle case or swap case) converts uppercase letters to lowercase and lowercase to uppercase. It's useful for: fixing incorrectly capitalized text, creating alternating case effects, normalizing inconsistent data, debugging case-sensitive issues, and meeting specific formatting requirements.
How does case inversion handle non-alphabetic characters?
Non-alphabetic characters remain unchanged: digits (0-9), punctuation, symbols, spaces, and special characters pass through unmodified. Only A-Z and a-z letters are affected. Unicode letters with diacritics (é, ñ, ü) are also inverted when supported by the browser.
What is the difference between invert case and other case transformations?
Invert case swaps existing case (A→a, a→A). Uppercase converts all to caps (HELLO). Lowercase converts all to small (hello). Title case capitalizes first letters (Hello World). Each serves different purposes: invert for toggling, uppercase for emphasis, lowercase for normalization, title case for headings.
Does invert case work with accented characters?
Modern browsers support Unicode case conversion, so accented letters like é↔É, ñ↔Ñ, ü↔Ü are inverted. However, support varies by browser and JavaScript engine. Simple ASCII (A-Z, a-z) works universally. Test with your specific characters if using extended Unicode.
What are common use cases for case inversion?
Common uses: fixing caps lock mistakes, alternating case for stylistic effect (mOcKiNg tExT), normalizing mixed-case data, debugging case-sensitive code or passwords, creating test data with varied casing, and reversing accidental double-capitalization.
How is case inversion implemented in programming?
Most languages provide case inversion: JavaScript uses char.toUpperCase() and char.toLowerCase() in a map; Python has str.swapcase(); PHP uses strtr with range mapping; Java has manual iteration with Character.isUpperCase(). The algorithm checks each character and applies the opposite case.