Use HTML Entity Encoder

Enter your data below to use the HTML Entity Encoder

📌 Try these examples:
RESULT

Last updated

What Are HTML Entities?

HTML entities are special codes used to represent characters that have special meaning in HTML or that cannot be typed directly. They start with & and end with ;. There are two forms: named entities (&) and numeric entities (& decimal or & hexadecimal).

Essential HTML Entities

CharacterNamed EntityNumericUse Case
&&&Ampersand in text/attributes
<&lt;&#60;Less-than sign (prevents tag parsing)
>&gt;&#62;Greater-than sign
"&quot;&#34;Double quote in attributes
'&apos;&#39;Single quote in attributes
 &nbsp;&#160;Non-breaking space
©&copy;&#169;Copyright symbol
&rarr;&#8594;Right arrow

Encoding and Decoding in JavaScript

JavaScript
// Encode HTML entities
function encodeHtmlEntities(str) {
  return str
    .replace(/&/g, '&')
    .replace(/</g, '<')
    .replace(/>/g, '>')
    .replace(/"/g, '"')
    .replace(/'/g, ''');
}

// Decode HTML entities (using DOM)
function decodeHtmlEntities(str) {
  const el = document.createElement('textarea');
  el.innerHTML = str;
  return el.value;
}

// Encode all non-ASCII characters as numeric entities
function encodeNonAscii(str) {
  return str.replace(/[^-]/g, char =>
    `&#${char.charCodeAt(0)};`
  );
}

encodeHtmlEntities('<script>alert("xss")</script>');
// → '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'

Frequently Asked Questions

Yes, completely free with no registration required. All processing happens in your browser.

Yes. All processing is 100% client-side — your data never leaves your browser.

Yes, the tool is fully responsive and works on all devices and browsers.