HTML Entity Encoder & Decoder

Convert <script> ↔ &lt;script&gt;. Encode escapes special characters so the browser shows them as literal text; decode reverses both named (&amp;) and numeric (&#x2764;) entities.

Output
Output appears here.
What are HTML entities?

Why they exist

HTML uses < and > to mark up tags. If you actually want to display a less-than sign on a page, you can't just type it β€” the browser will think you're starting a tag. HTML entities solve this by replacing each problem character with a placeholder the browser knows how to render as text.

The five basic entities

  • &lt; β€” less-than <
  • &gt; β€” greater-than >
  • &amp; β€” ampersand &
  • &quot; β€” double quote "
  • &#39; β€” apostrophe ' (named form &apos; works in HTML5 but not older HTML)

Numeric entities

Any Unicode character can be written as &#NNN; (decimal) or &#xHHH; (hex). Example: &#x2764; = ❀. Useful for emoji or characters your keyboard doesn't have.

Security context

HTML entity encoding is the foundation of XSS prevention. When you take user input and render it in a page, you encode it first β€” that way <script> becomes literal text instead of executable script. Every modern templating engine does this automatically.