JSFiddle - React, Tailwind, and code Playground

by Mottie

JavaScript

var s = 'This is &agrave; string <br> &amp; this is a second line. Insecure? <img src="bla" onerror="alert(1)">';
var decoded = HtmlDecode(s);
alert(decoded);

function HtmlDecode(html) {
    var txt, div = document.createElement("div");
    div.innerHTML = html;
    txt = div.textContent;
    div = null;
    return txt;
}