XML Input

Escaped Output

XML Escape Examples

Special characters (&, <, >, ", ') must be escaped in XML. Telecom-themed example:

Call log with special characters

Raw XML (note contains &lt;, &amp;, quotes):

Raw input

Escaped output:

Escaped output

Use Sample above to load a call log into the editor.

What Is XML Escape/Unescape?

XML reserves certain characters for markup: &, <, >, ", and '. When these appear in text content or attribute values, they must be escaped as entities (&amp;, &lt;, etc.) or the parser will misinterpret them. The W3C XML specification defines entity references. Unescaping does the reverse: it turns entities back into the actual characters.

Pick Escape or Unescape with the toggle at the top. Whichever you choose, the entity substitution is done locally by the page, so production XML or anything sensitive is fine to paste in.

How to Use This Tool

1

Choose Mode and Paste

The page opens in Escape mode. Paste a fragment such as a <note> body on the left, or pick a .xml or .txt file with Upload. Toggle switches to Unescape and also swaps the two panes, so whatever you just escaped becomes the new input.

2

View the Output

The right panel updates automatically. In Escape mode, reserved characters become entities. In Unescape mode, entities become the actual characters. Invalid or malformed input may produce unexpected results: validate with XML Validator if needed.

3

Copy or Download

When the entities look right, Copy grabs the text and Download stores it in a file. Escaping for JSON instead? Use JSON Escape. For URL encoding, use XML URL Encode.

When XML Escaping Matters

When embedding user input or dynamic content in XML, unescaped < or & can break parsing or create security issues. Escaping ensures the content is treated as text, not markup. When you receive double-escaped XML (e.g. from a database or API that stores XML as a string), unescaping removes the extra layer so you can parse it correctly.

Frequently Asked Questions

When do I need to escape?

When embedding user input or special characters in XML text content or attributes. Browsers and parsers expect entities for reserved chars. Unescaped < can be interpreted as the start of a tag; & as the start of an entity.

What about CDATA?

CDATA sections (<![CDATA[...]]>) avoid escaping for large blocks of text. But ]]> must still be escaped or split inside CDATA, as it ends the section. The W3C XML spec defines CDATA rules.

Is my data private?

Yes. Both directions run in this tab, and nothing is posted anywhere. Unescape decodes the five named entities plus numeric references like &#60; and &#x3C;, in one pass, so a double-escaped &amp;lt; loses one layer and comes back as &lt;. A reference to a character XML forbids, such as &#0;, is left as typed.

What XML characters must be escaped?

Five characters are reserved in XML and must always be escaped: & → &amp;, < → &lt;, > → &gt;, " → &quot;, and ' → &apos;. The ampersand and less-than sign are strictly required; the others are required in specific contexts (e.g. quotes inside attribute values).

Related Tools

The W3C XML entity references section names the five predefined entities this page swaps, and the rest of the W3C XML specification says where each one is mandatory. W3C XML collects the related standards. In your own code you rarely escape by hand: load the document with MDN DOMParser, set textContent, and XMLSerializer writes the entities for you. Coming from HTML? The HTML named character references list has over two thousand names that XML rejects, such as &nbsp;. Strings bound for JSON follow the JSON specification instead.