Free HTML escape & unescape tool — entities, XSS-safe output, display code

Escaping runs entirely in your browser — nothing is uploaded.

🔤 HTML Escape / Unescape — Free Online Tool

Escape and unescape HTML entities online, free. HTML escaping converts characters that the browser would treat as markup — <, >, &, ", ' — into their HTML entities so they render as literal text instead of becoming tags. This tool escapes text into HTML-safe entities, or unescapes entities back to characters, entirely in your browser, and is a core defence when displaying untrusted text.

🚀 Why use this HTML Escape / Unescape tool?

Escaping the markup characters when you insert untrusted text into HTML is a core defence against cross-site scripting (XSS). 100% free, no registration, and complete privacy — everything runs locally in your browser, so your data never touches a server.

Key Features

🛡️XSS-safe output

Converts <, >, &, " and ' to entities so untrusted text can't become live markup or scripts.

🔁Escape & unescape

Turn text into HTML entities, or decode entities like &lt;div&gt; back to characters.

Instant & in-browser

Runs locally as you type — no upload, no wait.

🔒100% private

Your markup and content never leave your device.

Popular Use Cases

Display code on a page

  • Show HTML snippets literally
  • Escape tags in docs/blogs
  • Render examples safely

Security

  • Escape untrusted user text
  • Sanitize before inserting to DOM
  • Prevent stored XSS

Content & email

  • Encode special characters
  • Decode scraped entities
  • Fix double-encoded text

What It Handles

Modes

  • Escape (text → entities)
  • Unescape (entities → text)

Handles

  • < > & " '
  • Numeric &#39;
  • Named entities

Privacy

  • Client-side only
  • No network calls
  • Runs offline

Sources & References

Frequently Asked Questions

How do I escape HTML to display code on a web page?

Convert the markup characters to entities: < becomes &lt;, > becomes &gt;, & becomes &amp;, " becomes &quot; and ' becomes &#39;. The browser then renders the literal characters instead of interpreting them as tags. Paste your snippet and click Escape.

Does HTML escaping prevent XSS?

Escaping these characters when you insert untrusted text into HTML is a core defence against cross-site scripting, because it stops user input from becoming live markup or scripts. Context matters though — values placed in attributes, URLs, or inline JavaScript need their own encoding, not just HTML-entity escaping.

Why does this tool use &#39; instead of &apos; for the apostrophe?

&apos; is an XML entity that was not part of HTML 4, so older browsers may not recognise it. The numeric reference &#39; works everywhere, so HTML escaping uses it. For XML output, use the XML Escape tool, which emits &apos;.

Is my HTML uploaded anywhere?

No. All escaping and unescaping happen in your browser with JavaScript. Your markup and content never leave your device.

How do I unescape HTML entities back to characters?

Paste text containing entities such as &lt;div&gt; and click Unescape. The tool turns &amp; &lt; &gt; &quot; and &#39; back into &, <, >, " and ', recovering the original characters.

🎓 Pro Tips

  • Tip 1: HTML-entity escaping covers text content; values in attributes, URLs, or inline JS need their own context-specific encoding.
  • Tip 2: Escape untrusted input as late as possible (at output time), so you store the original and encode for each context.
  • Tip 3: For XML output use XML Escape (&apos;), not HTML Escape (&#39;) — the apostrophe handling differs.