Javascript: Decode HTML entities

The following function decode HTML entities en return a plain text string:

function entityDecode(strHTML) {
  var tmpTextArea = document.createElement("textarea");
  tmpTextArea.innerHTML = strHTML.replace(/</g,"<").replace(/>/g,">");
  var decodedStr = tmpTextArea.value;
  return decodedStr;

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.