DevToolbox

Free Online HTML Encoder / Decoder

Encode HTML special characters to entities or decode HTML entities back to text β€” free online tool, prevents XSS, 100% client-side.

100% Client-Side Β· Your data never leaves your browser

How to Use HTML Encoder / Decoder

Choose a direction: Encoding converts raw HTML into safe entity-escaped text; Decoding converts entity sequences back to their original characters.

When encoding, pick a mode:

  • Minimal β€” encodes only the five HTML-unsafe characters (&, <, >, ", '). Use this for XSS prevention.
  • All non-ASCII β€” additionally encodes every character outside the printable ASCII range as a numeric entity. Use this when you need maximum compatibility.

Click Load sample to see a realistic example, then click Encode (or Ctrl/Cmd+Enter) to process it. Use the swap button to reverse direction.

Frequently Asked Questions

What are HTML entities?

HTML entities are escape sequences that represent characters with special meaning in HTML. For example, &lt; represents < (the start of a tag) and &amp; represents & (the start of an entity). Using entities prevents browsers from misinterpreting these characters as markup.

When should I encode HTML?

Always encode user-supplied text before inserting it into HTML to prevent Cross-Site Scripting (XSS) attacks. You also need encoding when embedding code samples in web pages, or when placing special characters like copyright symbols inside HTML attributes.

What is the difference between Minimal and All non-ASCII encoding?

Minimal mode encodes only the five characters that are dangerous in HTML: &amp;, &lt;, &gt;, &quot;, and &#39;. This is sufficient for XSS prevention. "All non-ASCII" additionally encodes any character outside the basic ASCII range as a numeric entity (&#169; for Β©), which is useful when the document charset is uncertain.

What is the difference between &amp;apos; and &amp;#39;?

&amp;apos; is an XML entity not officially supported in older HTML. &amp;#39; is the numeric decimal entity for a single quote and works in all HTML versions. Both decode to the same apostrophe character.

How does HTML decoding work?

Decoding converts entities back to their original characters: &amp;amp; becomes &amp;, &amp;lt; becomes &lt;, numeric entities like &amp;#169; and hex entities like &amp;#xA9; both become Β©. This tool handles named, decimal, and hexadecimal entities.

Related Tools