The Util Box

XML Escape/Unescape

Free online xml escape/unescape for developers. Escape/unescape XML special characters. Fast and private.

Escaped
Enter text above

Embed this tool

Copy and paste the code below into your website to embed this tool for free. An attribution link to The Util Box is required.

<iframe src="https://www.theutilbox.org/embed/xml-escape-unescape" width="600" height="500" frameborder="0" style="border: none; max-width: 100%;" title="Free XML Escape/Unescape tool from The Util Box"></iframe>
<!-- Free tool by The Util Box — https://www.theutilbox.org/tools/xml-escape-unescape -->
<a href="https://www.theutilbox.org/tools/xml-escape-unescape">XML Escape/Unescape by The Util Box</a>

Frequently Asked Questions about XML Escape/Unescape

XML Escape & Unescape — Handle the Five Predefined Entities

This XML escape and unescape tool converts text to and from XML's five predefined entities. Type text and it becomes safe to drop into an XML element or attribute; paste escaped XML and it becomes readable again.

XML predefines exactly five entities, and the tool handles all of them in both directions.

The Five Entities

Character Entity Why it matters
& &amp; Without it, a bare ampersand is malformed XML.
< &lt; Starts a tag — it would otherwise end your element early.
> &gt; Required in the ]]> sequence, and good practice everywhere else.
" &quot; Must be escaped inside a double-quoted attribute value.
' &apos; Must be escaped inside a single-quoted attribute value.

The escaping order matters and the tool gets it right: the ampersand is replaced first, so the ampersands introduced by the later replacements are not escaped a second time. Unescaping runs in the reverse order, with &amp; handled last, so &amp;lt; correctly comes back as &lt; rather than collapsing all the way to <.

Limits Worth Knowing

  • Numeric character references are not handled. &#38; and &#x26; pass through untouched in both directions.
  • CDATA sections are not recognised. Text inside <![CDATA[ ]]> is not specially treated.
  • Escaping is not context-aware. Running a whole XML document through it escapes the tags as well, producing a text blob rather than a document with escaped content. Use it on the values, not on the markup.
  • It does not validate. The output is not checked to be well-formed XML, and no schema or DTD is consulted.

Related Developer Tools

The conversion runs entirely in your browser, so nothing you paste is uploaded.