HTML Escape / Unescape

Escape the characters HTML treats as markup, or turn character references back into text. It runs in your browser: the text you paste never leaves your device.

Direction

Your text stays in your browser. This page sends it nowhere and makes no network request while you type.

What is escaped

A character reference starts with an ampersand and ends with a semicolon, and stands for one character [1]. Escape writes the five characters below as references. Turn on the option to also write every non-ASCII character as a decimal number, one reference per character, so an emoji is one reference.

& → &amp; < → &lt; > → &gt; " → &quot; ' → &#39;

How unescape reads references

Unescape reads the 2,125 named references that end in a semicolon from the standard’s table [3](the page was last updated 12 November 2026), plus decimal (&#233;) and hexadecimal (&#xE9;) numbers. A number of 0, a surrogate, or above 10FFFF becomes U+FFFD, and 128 to 159 map through the standard’s Windows-1252 table[2]. Anything else is left as written. Unescape runs once: &amp;lt; becomes &lt;, not <.

Example

Input: <a href="x">Tom & Jerry's café 😀</a>

  1. Escape: &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&#39;s café 😀&lt;/a&gt;
  2. Escape with non-ASCII as numbers: &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&#39;s caf&#233; &#128512;&lt;/a&gt; (é is 233, the emoji 128512)
  3. Unescape either one and you get the input back.

Questions

Does my text leave my device?

No. The page does the work in your browser and sends nothing anywhere. It makes no network request while you type or paste.

Which characters should I escape?

This tool escapes & < > " and '. Which characters need escaping depends on where the text goes, such as page text or a quoted attribute value. It does not sanitize HTML or judge whether text is safe to publish.

Why &#39; and not &apos;?

' is a numeric reference, understood wherever character references are. Unescape also reads ', because it is in the standard’s table [3].

What happens to unknown names or a missing semicolon?

They are left exactly as written, and the tool lists unknown names. It reads only references that end in a semicolon.

Why did &#150; become an en dash?

The HTML standard maps the numbers 128 to 159 through a Windows-1252 table, so – is “–”, not a control character [2].

Sources

  1. WHATWG. HTML Living Standard, 13.1.4 Character references. Accessed .
  2. WHATWG. HTML Living Standard, 13.2.5 Tokenization: Numeric character reference end state. Accessed .
  3. WHATWG. HTML Living Standard, 13.5 Named character references. Accessed .

Last updated .