Paste text on the left, choose transformations, then click "Transform".
Trim leading/trailing whitespace
Collapse multiple spaces to a single space
Normalize Windows/Mac newlines to "\n"
Convert to UPPERCASE
Remove completely blank lines
Transform
Copy output
<script>
// Core transformation pipeline definition.
// Each entry: { id: 'checkboxId', fn: text => newText }
const TRANSFORMS = [
{
id: "cbTrim",
fn: text => text.trim()
},
{
id: "cbCollapseSpaces",
fn: text => text.replace(/ {2,}/g, " ")
},
{
id: "cbNormalizeNewlines",
fn: text => text.replace(/\r\n?/g, "\n")
},
{
id: "cbUppercase",
fn: text => text.toUpperCase()
},
{
id: "cbRemoveBlankLines",
fn: text => text
.split(/\r?\n/)
.filter(line => line.trim() !== "")
.join("\n")
}
// Add more transformation objects here
];
const inputEl = document.getElementById("inputText");
const outputEl = document.getElementById("outputText");
const statusEl = document.getElementById("status");
const btnTransform = document.getElementById("btnTransform");
const btnCopy = document.getElementById("btnCopy");
function runPipeline() {
let text = inputEl.value;
for (const t of TRANSFORMS) {
const checkbox = document.getElementById(t.id);
if (checkbox && checkbox.checked) {
text = t.fn(text);
}
}
outputEl.value = text;
statusEl.textContent = "Transformed at " + new Date().toLocaleTimeString();
}
btnTransform.addEventListener("click", runPipeline);
btnCopy.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(outputEl.value);
statusEl.textContent = "Output copied to clipboard";
} catch (err) {
statusEl.textContent = "Copy failed (browser permissions)";
}
});
// Optional: auto-run when input changes
// inputEl.addEventListener("input", runPipeline);
</script>