HTML Entity Encoder

Encode and decode HTML entities.

Common HTML Entities

CharNamedDecimalHex
& & & &
< &lt; &#60; &#x3C;
> &gt; &#62; &#x3E;
" &quot; &#34; &#x22;
' &apos; &#39; &#x27;
© &copy; &#169; &#xA9;
® &reg; &#174; &#xAE;
&trade; &#8482; &#x2122;
&euro; &#8364; &#x20AC;
£ &pound; &#163; &#xA3;

Frequently Asked Questions

What are HTML entities and why are they needed?

HTML entities are special codes that represent characters which have meaning in HTML syntax (like <, >, &, ") or characters not available on standard keyboards. For example, < must be written as &lt; in HTML to avoid being interpreted as a tag. Entities prevent rendering errors and security vulnerabilities like XSS attacks.

What is the difference between named and numeric entities?

Named entities use memorable names like &amp; for &, &lt; for <, and &nbsp; for non-breaking space. Numeric entities use the Unicode code point: &#38; (decimal) or &#x26; (hexadecimal) for &. Numeric entities can represent any Unicode character; named entities only cover a defined set.

Which characters should I encode in HTML?

At minimum, always encode the five special HTML characters: < (&lt;), > (&gt;), & (&amp;), " (&quot;), and ' (&#39; or &apos;). For maximum compatibility, also encode non-ASCII characters like accented letters and special symbols, especially if your page encoding is not UTF-8.

Can I use this tool to prevent XSS attacks?

Encoding user input as HTML entities is a key defense against Cross-Site Scripting (XSS). Converting < and > to &lt; and &gt; prevents injected script tags from executing. However, proper XSS prevention requires server-side encoding and Content Security Policy headers — client-side encoding alone is not sufficient.

Does the decoder handle all entity formats?

Yes — the decoder recognizes named entities (&amp;), decimal numeric entities (&#38;), and hexadecimal numeric entities (&#x26;). It handles all 2,231 named HTML entities defined in the HTML5 specification and any valid Unicode code point in numeric format.