CoderTools

HTML Encoder/Decoder

Convert special characters to HTML entities to prevent XSS attacks

Common HTML Entities Reference

Character Named Entity Decimal Hexadecimal Description
< &lt; &#60; &#x3C; Less than sign (tag start)
> &gt; &#62; &#x3E; Greater than sign (tag end)
& &amp; &#38; &#x26; Ampersand (entity start)
" &quot; &#34; &#x22; Double quotation mark
' &apos; &#39; &#x27; Single quote/apostrophe
  &nbsp; &#160; &#xA0; Non-breaking space
© &copy; &#169; &#xA9; Copyright symbol
® &reg; &#174; &#xAE; Registered trademark symbol
&trade; &#8482; &#x2122; Trademark symbol

About HTML Encoding

HTML encoding is the process of converting special characters to HTML entities. Certain characters have special meaning in HTML (like < and >), and using them directly could break page structure or cause security issues.

By converting these characters to their corresponding HTML entities, browsers can display them correctly without interpreting them as HTML markup. This is an important security measure in web development to prevent XSS (Cross-Site Scripting) attacks.

Security Note: Always HTML-encode user input before displaying it on a web page. This is a fundamental security measure to prevent XSS attacks.

Common Use Cases

Entity Types Explained

Named Entities

Use easy-to-remember names, good readability, but not all characters have named entities

&lt; &gt; &amp; &nbsp;

Decimal Entities

Use character Unicode code point (decimal), works for all characters

&#60; &#62; &#38; &#160;

Hexadecimal Entities

Use character Unicode code point (hex), consistent with CSS and JavaScript

&#x3C; &#x3E; &#x26; &#xA0;

References