Text & Encoding

HTML Escape & Unescape

Convert special characters to safe HTML entities and decode entity strings.

Runs 100% locally in your browser
Submitted HTML is processed strictly as inert text—never parsed or executed in the browser DOM.

What Does the HTML Escape & Unescape Do?

The HTML Escape & Unescape tool converts reserved HTML syntax characters (&, <, >, ", and ') into their corresponding character entity references (&amp;, &lt;, &gt;, &quot;, &#39;) so code snippets and untrusted text can be displayed safely inside HTML documents.

In Unescape mode, it reverses both named entities (such as &amp;, &lt;, &copy;, &nbsp;, &mdash;) and decimal or hexadecimal numeric character references (such as &#169; or &#x1F680;) back into plain Unicode characters.

Security guarantee: Unescaping is performed purely via string and code-point parsing—submitted HTML is never injected into innerHTML or executed by the browser DOM.

How to Use This Tool

  1. Select 'Escape HTML' or 'Unescape HTML' (or load an example snippet).
  2. When escaping, optionally toggle 'Also encode non-ASCII Unicode characters as numeric entities' if targeting strict ASCII environments.
  3. Copy the escaped or unescaped output directly to your clipboard.

Common Engineering Use Cases

  • Preparing HTML, XML, or JSX code snippets to be embedded inside <pre><code> blocks in documentation or blog posts.
  • Decoding HTML-escaped strings returned by legacy RSS feeds, CMS APIs, or scraped metadata.
  • Testing how special characters and Unicode symbols are represented as numeric character references.

Practical Developer Examples

Escaping an HTML Script Tag for Safe Display

Converting angle brackets and quotes prevents the browser from interpreting the string as executable markup.

Input
<script src="app.js" data-env='prod'>alert("XSS & test");</script>
Output
&lt;script src=&quot;app.js&quot; data-env=&#39;prod&#39;&gt;alert(&quot;XSS &amp; test&quot;);&lt;/script&gt;

Common Mistakes & Pitfalls to Avoid

  • Escaping '&' last instead of first when writing custom replace chains, which accidentally turns '&lt;' into '&amp;lt;'.
  • Using innerHTML to decode HTML entities in client-side JavaScript, which introduces Cross-Site Scripting (XSS) vulnerabilities.
  • Relying on HTML entity escaping inside <script> tags, href="javascript:..." attributes, or unquoted attributes where HTML entities do not prevent script execution.

Frequently Asked Questions

Does this tool execute or render the HTML I paste?

Never. All transformations use pure deterministic string and Unicode code-point routines and are rendered inside plain text editors, eliminating any risk of script execution.