JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    <ol>
        #1: <pre id="normal"></pre></li>
        #2: <pre id="spacesOnly"></pre></li>
    </ol>
</div>

JavaScript

function htmlDecode(input){
  var e = document.createElement('div');
  e.innerHTML = input;
  return e.childNodes[0].nodeValue;
}

$("#normal").text(htmlDecode("&lt;img src='myimage.jpg'&gt;"));
$("#spacesOnly").text(htmlDecode(" "));