HTML Encode / Decode

HTML Encode / Decode

About HTML Encode / Decode

HTML encode online and HTML decode online with our free HTML entity encoder. Convert special characters to and from HTML entities for safe display in web pages. Use this tool to prevent XSS attacks, display code in HTML, and safely render user input. Works as an HTML entity encoder and HTML decode tool in your browser.

Example

Input

<script>alert("XSS")</script>

Output

&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;

Why Use HTML Encode / Decode?

  • Prevent XSS attacks — Encode user input so it is treated as text, not executable HTML or JavaScript.
  • Display code in HTML — Show code snippets, tags, and special characters without them being interpreted by the browser.
  • Safe user input rendering — Render untrusted content safely in web applications and documentation.

HTML Encode / Decode FAQs

What is HTML encoding?

HTML encoding converts special characters into HTML entities so they display correctly in web pages. For example, < becomes &lt; and & becomes &amp;.

Why is HTML encoding important?

HTML encoding prevents cross-site scripting (XSS) attacks by ensuring user input is treated as text, not executable HTML or JavaScript.

When should I decode HTML entities?

Decode HTML entities when you need to extract the original text from HTML source code, or when processing content from APIs that return HTML-encoded strings.

What are the most common HTML entities?

&amp; &lt; &gt; &quot; &#39; are the five most common HTML entities, representing ampersand, less-than, greater-than, double quote, and apostrophe respectively.

Does HTML encoding affect SEO?

No. Search engines parse HTML entities correctly, so encoded content is indexed the same as unencoded content.