Skip to content

HTML Escaper

Escape <, >, &, double quotes and apostrophes as HTML entities, or unescape HTML entities back to characters.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is HTML Escaper?

This HTML escape and unescape tool converts the characters that have special meaning in HTML into entities, and back. Escaping turns < into &lt;, > into &gt;, & into &amp;, " into &quot; and ' into &#39;, so text displays literally instead of being interpreted as markup. That is how you show code samples on a web page, and it is the core defence against cross-site scripting (XSS) when inserting user-provided text into HTML.

Unescaping does the reverse: paste text full of &amp;, &lt; or numeric entities such as &#169; and &#x1F600; and get readable characters back.

How to use HTML Escaper

  1. Choose Escape to convert special characters to entities, or Unescape to convert entities back.
  2. Paste your text or HTML into the input panel.
  3. The result appears in the output panel instantly.
  4. Copy it into your template, documentation or code.

Key features

  • Escapes &, <, >, " and ' to HTML entities
  • Unescapes core named entities and all numeric entities
  • Decimal (&#169;) and hexadecimal (&#xA9;) entity support
  • Instant output as you type
  • Runs entirely in your browser

Common use cases

  • Displaying HTML and code samples on web pages and blogs
  • Escaping user-provided text before inserting it into HTML
  • Decoding entity-encoded text from RSS feeds, APIs and CMS exports
  • Preparing text for HTML attributes and email templates
  • Fixing double-escaped content such as &amp;lt;

Technical details & standards

Escaping replaces the five characters that matter in HTML: & with &amp;, < with &lt;, > with &gt;, " with &quot; and ' with &#39;. Everything else, including non-English text and emoji, is left as is, which is correct for UTF-8 pages.

Unescaping decodes &amp;, &lt;, &gt;, &quot; and &#39; (or &#039;) plus any numeric entity, decimal (&#169;) or hexadecimal (&#xA9;). Other named entities such as &nbsp; or &copy; are left unchanged; write them as numeric entities (&#160;, &#169;) to decode them. Escaping is context-dependent: this protects text in element content and quoted attribute values, but URLs and JavaScript contexts need their own encoding.

HTML escape characters

The five characters this tool escapes, followed by named entities you will see often in HTML. Any character can also be written as a decimal or hex numeric entity, which this tool decodes when unescaping.

CharacterNamed entityDecimalHexNotes
&&amp;&#38;&#x26;Escaped by this tool; starts every entity
<&lt;&#60;&#x3C;Escaped by this tool; starts a tag
>&gt;&#62;&#x3E;Escaped by this tool
"&quot;&#34;&#x22;Escaped by this tool; closes double-quoted attributes
'&apos;&#39;&#x27;Escaped by this tool as &#39;, which also works in HTML 4
(nbsp)&nbsp;&#160;&#xA0;Non-breaking space
©&copy;&#169;&#xA9;Copyright sign
®&reg;&#174;&#xAE;Registered trademark
™&trade;&#8482;&#x2122;Trademark
€&euro;&#8364;&#x20AC;Euro
£&pound;&#163;&#xA3;Pound sterling
¥&yen;&#165;&#xA5;Yen
°&deg;&#176;&#xB0;Degree
×&times;&#215;&#xD7;Multiplication sign
÷&divide;&#247;&#xF7;Division sign
–&ndash;&#8211;&#x2013;En dash
—&mdash;&#8212;&#x2014;Em dash
…&hellip;&#8230;&#x2026;Ellipsis
«&laquo;&#171;&#xAB;Left angle quote
»&raquo;&#187;&#xBB;Right angle quote
•&bull;&#8226;&#x2022;Bullet
→&rarr;&#8594;&#x2192;Right arrow

Frequently asked questions

Which characters must be escaped in HTML?

& and < always in text content, and the quote character used around an attribute value inside that attribute. Escaping all five of &, <, >, " and ' is the safe default.

Does HTML escaping prevent XSS?

It prevents XSS when text is placed in HTML element content or quoted attributes. Text placed in URLs, inline JavaScript or CSS needs context-specific encoding, so use your template engine's auto-escaping and a Content Security Policy as well.

What does &amp;lt; mean?

Double escaping: &lt; was escaped again, turning its & into &amp;. Unescape twice to get <, and fix the code that escapes the text twice.

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

Both represent an apostrophe. &apos; is defined in HTML5 and XML but not HTML 4, so &#39; is the most compatible choice and is what this tool produces.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More encoders & decoders tools

View all