PXLTools

HTML Entity Encoder

Encode and decode HTML entities

How to use HTML Entity Encoder

  1. Choose Encode or Decode mode.
  2. Paste your text into the input area.
  3. The output updates in real time.
  4. Enable Encode all non-ASCII to convert unicode characters to numeric entities.

HTML entities explained

HTML entities represent reserved characters in HTML. When you write < in HTML, the browser interprets it as the start of a tag. To display a literal less-than sign, you write &lt; instead.

There are named entities (&amp;, &lt;, &copy;) and numeric entities (&#38;, &#60;, &#169;). Named entities are easier to read in source code. Numeric entities work for any Unicode character.

Encoding user-generated content before inserting it into HTML is a fundamental security practice that prevents cross-site scripting (XSS) attacks.

Frequently Asked Questions

What characters need to be encoded in HTML?
The five mandatory characters are: & (&amp;), < (&lt;), > (&gt;), " (&quot;), and ' (&#39;). These have special meaning in HTML and must be escaped to display literally.
Should I encode all characters or just special ones?
For most cases, encoding only special characters (&, <, >, ", ') is sufficient. Full encoding (all non-ASCII to numeric entities) is useful when you need ASCII-safe output.
What is the difference between named and numeric entities?
Named entities like &amp; are human-readable. Numeric entities like &#38; use the Unicode code point. Both produce the same result in browsers.
Is this useful for preventing XSS?
Yes. Encoding user input before inserting it into HTML prevents script injection. However, proper output encoding should be done server-side, not manually.