SnapTools
All tools

HTML Entity Encoder / Decoder

Encode special characters to HTML entities (< > & " ') or decode entities back to text. Useful for safe HTML output and parsing.

About this tool

HTML entities represent special characters so they display correctly and don't break markup. For example, < becomes < and & becomes &. Encoding user input before putting it in HTML helps prevent XSS. Decoding is needed when you have entity-encoded text and want plain characters back.

How to use

  • Paste the text you want to encode (e.g. text containing <, >, &) or entity-encoded text to decode.
  • Click Encode to turn special characters into HTML entities.
  • Click Decode to turn entities back into normal characters.

When to use this tool

  • Displaying user input safely in HTML (e.g. &lt; and &gt; so it doesn't become a tag).
  • Preventing XSS: encode before inserting text into the DOM.
  • Decoding HTML entities from scraped content or API responses.
  • Converting special quotes or symbols to entities for consistent rendering.

Tips

  • Always encode user-generated content before showing it in HTML to avoid injection and broken layout.
  • Numeric entities (e.g. &#39; or &#x27;) are supported on decode; we convert them back to the character.

FAQ

What characters get encoded?
Common ones: & → &amp;, < → &lt;, > → &gt;, " → &quot;, ' → &#39;, / → &#x2F;. Encoding these prevents HTML from being interpreted or broken.
Is this enough to prevent XSS?
Encoding for HTML context (e.g. text content) helps. For attributes, JavaScript, or URL contexts, use the right encoding for that context. This tool is for HTML text content.