How do I decode/unescape html entities in a string
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
console.log( htmlDecode("<img src='myimage.jpg'>") )
// "<img src='myimage.jpg'>"
console.log( htmlDecode("<img sr='dummy' onerro='alert(/xss/)'>") )
// ""
https://stackoverflow.com/questions/1912501/unescape-html-entities-in-javascript