XML Escape

XML Escape

Updated August 20, 2026

XML escape and unescape online. Encode or decode &, <, >, and quotes for XML text. Free XML encoder in your browser.

Input

Output

Features

  • Escape & < > " ' for XML text or attributes
  • Unescape named and numeric character references
  • Switch between escape and unescape
  • Preview the result immediately
  • Copy the safe string into a document or code
  • No server round-trip

Common Use Cases

  • Put a URL with query string into an XML text node
  • Embed a snippet of code in a docbook or config value
  • Undo &amp;amp;lt; chains from double-escaped logs
  • Prepare attribute values that contain quotes
  • Explain to a teammate why Tom &amp; Jerry broke the parser

The five characters XML reserves

In character data, & and < must be escaped. > is often escaped for symmetry. In attributes, quotes need &quot; or &apos; depending on the delimiter.

Numeric references like &#169; and &#xA9; decode to Unicode. Unescape applies named entities we listed plus numeric forms. HTML-only names like &nbsp; are not XML unless a DTD defined them.

Examples

Invalid - Needs escape
Tom & Jerry <show>
Valid - Escaped
Tom &amp; Jerry &lt;show&gt;
Valid - Numeric entity
&#x41;

Frequently Asked Questions

Should I escape inside CDATA?

No. CDATA is raw except for the sequence ]]>. Do not double-escape there.

Is this HTML entity encoding?

Close, but HTML has a much larger named-entity list. XML without a DTD only guarantees &amp; &lt; &gt; &apos; &quot; plus numeric forms.

Tips

  • Escape first, then wrap in tags. Do not escape the tags themselves.
  • If you see &amp;amp;amp;, the value was escaped more than once. Unescape until it looks like the original text.