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,">");
  var decodedStr = tmpTextArea.value;
  document.removeElement(tmpTextArea);

  return decodedStr;
}

Questions or comments?

Join the discussion on Discord, ask a question or share your experience.

Discuss on Discord
  1. JSBricks game screen with bricks, paddle and ballProjects: JSBricks, an arkanoid clone in javascript
  2. Javascript: Check if any checkbox is checked
  3. 20201212_174208DIY volumio driven audiophile DAC and CD player