XML Escape and Unescape

Escape text for XML or HTML using the five predefined entities, or unescape entities back to plain characters.

Independently verified for accuracy

Calculator by Toolsloft ↗

Escape text so it is safe to drop inside an XML or HTML document, or unescape entities back to plain characters. It handles the five predefined XML entities for the ampersand, less-than, greater-than, quote, and apostrophe. Handy when you are building feeds, config files, or markup by hand.

How this is calculated

Escaping replaces the five reserved characters with their named entities: & becomes &amp;, < becomes &lt;, > becomes &gt;, the double quote becomes &quot;, and the apostrophe becomes &apos;. The ampersand is replaced first so nothing is double-encoded. Unescaping reverses this and restores &amp; last.

How to use

  1. Choose escape to encode reserved characters, or unescape to decode entities.
  2. Type or paste your text into the input box.
  3. Copy the converted result.

Examples

  • Escape: 5 < 10 becomes 5 &lt; 10
  • Unescape: &amp; becomes &

FAQ

Which characters get escaped?
The five predefined XML entities: the ampersand (&amp;), less-than (&lt;), greater-than (&gt;), double quote (&quot;), and apostrophe (&apos;). These are the characters that would otherwise be read as markup.
Why is the ampersand replaced first?
Every entity begins with an ampersand, so if & were not replaced first, the ampersands added by the other replacements would be encoded again and you would get output like &amp;lt;. Doing & first avoids that.
Does this handle numeric entities like &#39;?
This tool converts the five named entities. It does not expand numeric character references, so unescaping focuses on &amp;, &lt;, &gt;, &quot;, and &apos;.

Embed this calculator

Add this free calculator to your own site. Copy the code and paste it where you want it to appear.