Encode HTML using JavaScript

To encode HTML:

const encodeHtml = html => {
  const d = document.createElement('div');
  d.textContent = html;
  return d.innerHTML;
}

Leave a Reply

Your email address will not be published.

Color scheme: