Text Case Converter tool

Text Case Converter tool

Case Converter Tool


`; outputContainer.innerHTML = result; } function copyToClipboard() { const outputText = outputContainer.textContent; const textarea = document.createElement('textarea'); textarea.value = outputText; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); alert('Text copied to clipboard!'); } function toTitleCase(text) { return text.replace(/\w\S*/g, function (word) { return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); }); } function toSentenceCase(text) { return text.charAt(0).toUpperCase() + text.slice(1); } function toCamelCase(text) { return text.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) { if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces return index === 0 ? match.toLowerCase() : match.toUpperCase(); }); } function toSnakeCase(text) { return text.replace(/\s+/g, '_').toLowerCase(); } function toKebabCase(text) { return text.replace(/\s+/g, '-').toLowerCase(); } });