What's the right way to decode a string that has special HTML entities in it?

That jQuery method might feel hacky, but it’s actually a common and safe approach. DOM parsing handles the decoding natively.

If you’re not using jQuery, you can do the same in vanilla JS:

function decodeHtml(html) {
  const txt = document.createElement("textarea");
  txt.innerHTML = html;
  return txt.value;
}

Super handy if you’re doing any javascript html decode tasks without extra libraries!