XML Escape

Escape special XML characters for safe inclusion in XML documents.

Escape the five characters that have special meaning in XML: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &apos;. Use it before putting text into XML elements or attribute values, so a stray ampersand or angle bracket doesn't break the document. XML unescape reverses it.

Need the reverse? XML Unescape

Common use cases

  • Put text containing & or < into an XML file
  • Prepare values for an XML or SOAP request
  • Fix a feed broken by an unescaped ampersand

How to use

  1. Paste the text.
  2. Copy the escaped result.

FAQ

Do I need to escape quotes?

Only inside attribute values that use the same kind of quote. Escaping all five characters is always safe.

What about CDATA?

A <![CDATA[ … ]]> section lets you include text without escaping, as long as it doesn't contain ]]>.