HTML Entity Encoder / Decoder

Convert special characters to HTML entities and back.

Common Entities Reference ▸
&&
<&lt;
>&gt;
"&quot;
'&#39;
©&copy;
®&reg;
&trade;
&euro;
£&pound;
¥&yen;
°&deg;
±&plusmn;
×&times;
÷&divide;
&rarr;
&larr;
&uarr;
&darr;
&harr;

About This Tool

HTML entities are special sequences representing characters that have reserved meaning in HTML, or characters not easily typed on a keyboard. They ensure browsers render the intended character rather than misinterpreting it as HTML markup.

When to Use

  • Escaping user-provided text before inserting into HTML to prevent XSS (Cross-Site Scripting).
  • Displaying code snippets with < and > characters in HTML.
  • Embedding copyright (©), trademark (™), or currency (€) symbols.

Practical Examples

XSS Prevention<script>alert(1)</script> → &lt;script&gt;alert(1)&lt;/script&gt; (safe to display)
Typographic"Hello" → &quot;Hello&quot; - required in HTML attributes

Common Mistakes to Avoid

  • Double-encoding: running encode twice turns & → &amp; → &amp;amp;.
  • Forgetting to escape user input in server-rendered HTML leads to stored XSS vulnerabilities.

Frequently Asked Questions

Q. When should I use &#number; vs &name;?A. Named entities (&amp;) are more readable. Numeric entities (&#38;) are portable across all parsers. Both are equivalent.

Related Tools