<label for="original">Original</label>
<textarea cols="50" rows="20" id="original" onkeyup="strip()">
  <div>
    <p>Hey that's <span><b>something</span></b></p>
  </div>    
  
  <p>paragraph</p>
  
  <h1>Big title</h1>
  <script>alert("i'm a hacker 🧐");</script>
</textarea>

<p>
  <button type="button" onclick="strip()">Strip it</button>
</p>

<label for="stripped">Stripped code</label>
<textarea cols="50" rows="20" id="stripped" disabled></textarea>
body {
  text-align: center;
}
label {
  vertical-align: top;
  display: block;
}

button {
  font-size: 2rem;
}
View Compiled
function strip(html) {
  const fakeDiv = document.createElement("div");
  fakeDiv.innerHTML = document.getElementById("original").value;
  document.getElementById("stripped").innerHTML =
    fakeDiv.textContent || fakeDiv.innerText || "";
}

strip();
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.