HTML Entities

Free online HTML entity encoder and decoder. Convert special characters to HTML entities and back. All processing happens locally in your browser.

Input
Output
 

How to Use HTML Entities

1

Enter Your HTML

Type or paste HTML code or text containing special characters into the input panel.

2

Choose Direction

Click "Encode" to convert special characters like <, >, & into HTML entities. Click "Decode" to convert entities back to regular characters.

3

Get the Result

The converted output appears instantly in the right panel. All processing happens locally in your browser.

Examples

Before (Raw HTML)

<div class="example">Hello & Welcome</div>

After (HTML Entities)

&lt;div class=&quot;example&quot;&gt;Hello &amp; Welcome&lt;/div&gt;

Frequently Asked Questions

What are HTML entities?

HTML entities are special codes used to display characters that have special meaning in HTML. For example, < is encoded as &amp;lt;, > as &amp;gt;, and & as &amp;amp;. Without encoding, these characters would be interpreted as HTML tags rather than displayed as text.

When should I use HTML entity encoding?

You should encode HTML entities whenever you display user-generated content on a web page to prevent XSS (Cross-Site Scripting) attacks. Also use it when you want to display HTML code as text, such as in documentation or code examples.

What is the difference between HTML entities and URL encoding?

HTML entities are for displaying special characters in HTML documents (e.g., &amp;lt; for <). URL encoding is for making URLs safe to transmit (e.g., %3C for <). They serve different purposes and use different encoding schemes.

What characters are encoded?

The main characters that need encoding are: & (ampersand) → &amp;amp;, < (less than) → &amp;lt;, > (greater than) → &amp;gt;, " (double quote) → &amp;quot;, and ' (single quote) → &amp;#39;. These are the five characters that have special meaning in HTML.

Why HTML Entity Encoding Matters

HTML entity encoding is a critical security practice for web developers. Without proper encoding, user input containing HTML tags or JavaScript could be executed in the browser, leading to XSS attacks. Encoding ensures that special characters are displayed as text, not interpreted as code.

The Five Essential HTML Entities

  • &amp; — ampersand (&)
  • &lt; — less than (<)
  • &gt; — greater than (>)
  • &quot; — double quote (")
  • &#39; — single quote (')

Related Tools

Related Articles