Case Converter Tool
Home
Snippets
Case Converter Tool
HTML
CSS
JS
<div class="container"> <textarea id="inputText" placeholder="Paste or type your text here..."></textarea> <div class="buttons"> <button onclick="convert('lower')">lowercase</button> <button onclick="convert('upper')">UPPERCASE</button> <button onclick="convert('title')">Title Case</button> <button onclick="clearText()">Clear</button> </div> <div class="output" id="outputText"></div> <button class="buttons copy-btn" onclick="copyText()">Copy Output</button> </div>
body { height: 100vh; margin: 0; padding: 100px 0; font-family: 'Segoe UI', sans-serif; background-color: #f9fafb; color: #111827; display: flex; align-items: center; justify-content: center } .container { width: 90%; max-width: 350px; background: #fff; padding: 24px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05); } textarea { width: 100%; height: 160px; padding: 12px; font-size: 16px; border-radius: 6px; border: 1px solid #d1d5db; resize: vertical; margin-bottom: 16px; box-sizing: border-box; } .buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; } .buttons button { flex: 1; min-width: 120px; padding: 10px 16px; border: none; border-radius: 6px; background: #444444; color: white; font-size: 14px; cursor: pointer; transition: background 0.2s; } .buttons button:hover { background: #2563eb; } .output { background: #f3f4f6; padding: 14px; border-radius: 6px; min-height: 100px; font-size: 15px; white-space: pre-wrap; border: 1px solid #e5e7eb; } .copy-btn { margin-top: 10px; background: #10b981; } .copy-btn:hover { background: #059669; }
function convert(type) { const text = document.getElementById("inputText").value; let result = ""; if (type === "lower") { result = text.toLowerCase(); } else if (type === "upper") { result = text.toUpperCase(); } else if (type === "title") { result = text .toLowerCase() .split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); } document.getElementById("outputText").textContent = result; } function copyText() { const output = document.getElementById("outputText").textContent; if (!output) return; navigator.clipboard.writeText(output).then(() => { alert("Copied to clipboard "); }); } function clearText() { document.getElementById("inputText").value = ""; document.getElementById("outputText").textContent = ""; }
Ad #1
Ad #2
Scroll to Top