HTML Encoder & Decoder | Free Online HTML Entity Converter

Encode HTML special characters to entities and decode them back. 100% free, works in browser — no data sent to server.

Your data never leaves your browser

Online HTML encoder and decoder tool

HTML Text

Result

HTML Entities & XSS Prevention Guide

HTML entity encoding converts reserved characters into character entity references, preventing web browsers from misinterpreting raw text as executable HTML markup.

Critical Safe Characters Table

&   &    Ampersand
<   &lt;     Less-than (starts an HTML tag)
>   &gt;     Greater-than (ends an HTML tag)
"   &quot;   Double quotation mark (attributes)
'   &#39;    Single quote / Apostrophe
©   &copy;   Copyright symbol
€   &euro;   Euro currency sign

Preventing Cross-Site Scripting (XSS)

If user-submitted data containing <script> is echoed directly into an HTML template without entity encoding, the browser executes the script as code. Encoding converts < to &lt; so the browser displays the literal characters safely as text.

Named vs Numeric Entities

Named entities like &quot; are easy for humans to read. Numeric entities like &#34; (decimal) or &#x22; (hex) are guaranteed to be recognized across older XML and strict XHTML parsers.

HTML Encoding vs URL Encoding

HTML encoding converts characters into entities for web page rendering (e.g. &amp;). URL encoding converts characters into percent-escapes (e.g. %26) for query strings and HTTP request transmission. Use HTML encoding for markup, URL encoding for links.

Frequently Asked Questions

How do I encode HTML special characters online?

Paste your raw HTML or text into the encoder input. The tool instantly converts characters like <, >, &, ", and ' into their safe HTML entity equivalents (&lt;, &gt;, &amp;, &quot;, &#39;).

When should I encode HTML entities?

You should encode HTML entities whenever you display user-generated content in a web page to prevent cross-site scripting (XSS) attacks. It ensures that browser interprets the characters as text, not markup.

What is the difference between HTML encoding and URL encoding?

HTML encoding converts characters to HTML entities for safe display in web pages (e.g., & becomes &amp;). URL encoding converts characters to percent-encoded sequences for safe transmission in URLs (e.g., & becomes %26).

Does this tool support all HTML named entities?

This tool handles the five most critical HTML entities: &lt;, &gt;, &amp;, &quot;, and &#39;. These cover the vast majority of XSS prevention use cases for rendering user content safely.