HTML Escape / Unescape

Escape or unescape HTML entities including named, decimal, and hex numeric entities.

HTML Entity Reference

CharacterHTML EntityNamed Entity
&&ampersand
<&lt;less-than
>&gt;greater-than
"&quot;double quote
'&#x27;single quote
&nbsp;non-breaking space
©&#169;copyright
®&#174;registered
&#8482;trademark

Where HTML Escaping Matters Most

  • Rendering user-generated contentComments, reviews, usernames and bios must be escaped before insertion into HTML, or a name like <script>alert(1)</script> becomes executable code.
  • Displaying code samplesA tutorial showing <div> or & in a <pre> block needs escaping, or the browser tries to parse it as real markup instead of showing it as text.
  • Building HTML email templatesEmail clients render raw HTML — unescaped user data in a template is as risky as it is in a web page.
  • Server-side templating without auto-escapingSome template engines and raw string concatenation don't escape by default — this tool lets you verify the escaped output before shipping it.

When to Escape HTML

ContextRequiredReason
User-generated content in HTMLYesPrevents XSS attacks
Code samples in <pre> blocksYesAngle brackets would close tags
Attribute valuesYesQuotes can break attributes
JSON in HTML <script>PartialEscape </script> closing tag
Template literals in JSNoUse JS string escaping instead

Frequently Asked Questions

HTML escaping converts special characters to HTML entities so browsers display them as text rather than interpreting them as markup.

Yes — escaping user input before inserting it into HTML prevents reflected and stored XSS. Always escape on output, not on input storage.

&apos; is valid in XML but NOT in HTML4. Use &#x27; for maximum compatibility across HTML4, HTML5, and XML.

Emoji and most Unicode characters do not need escaping in UTF-8 HTML5. Only the 5 special characters (&, <, >, ", ') must be escaped.

Frameworks like React and Vue auto-escape text interpolated into JSX/templates by default, which covers the common case. You still need to escape manually when building raw HTML strings, writing to innerHTML, generating server-side email templates, or using an explicit 'render raw HTML' escape hatch (like dangerouslySetInnerHTML) with untrusted input.

Related Tools