XML Escape

Escape special characters in XML strings.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What XML Escape does

XML Escape replaces the five characters that have a meaning in XML with the five entities every XML parser knows: & < > " '. The result is safe in element text and in attribute values in either kind of quotes.

XML 1.0 forbids most control characters (U+0000 to U+0008, U+000B, U+000C and U+000E to U+001F) anywhere in a document, even as character references. If the input contains one, the tool reports where instead of producing a file that no parser will accept.

XML Escape examples

The built-in sample

Input

say "hello" & <b>bye</b>

Output

say &quot;hello&quot; &amp; &lt;b&gt;bye&lt;/b&gt;

This is the input that the Load sample button fills in.

Markup and both quote kinds

Input

<note to="Tom & Jerry">It's "done"</note>

Output

&lt;note to=&quot;Tom &amp; Jerry&quot;&gt;It&apos;s &quot;done&quot;&lt;/note&gt;

Both quote kinds are escaped, so the text can go in either kind of attribute.

A character XML forbids

Input

Line one␁line two

Result

U+0001 is not allowed anywhere in an XML 1.0 document, escaped or not (line 1, column 9)

U+0001 cannot appear in XML 1.0 at all, so the tool reports it.

Each output was produced by running this tool on the input above it. Invisible control characters are shown as symbols, for example ␁ for U+0001 and ␀ for U+0000.

How it works

Each of these characters is replaced; all other characters are copied unchanged.

CharacterWritten as
&&amp;
<&lt;
>&gt;
"&quot;
'&apos;

Details and limits

  • Escaping > is optional in XML except after ]]; it is escaped anyway so the output is safe everywhere.
  • For HTML, use HTML Escape, which writes &#39; for the apostrophe.

Questions

Is my data uploaded when I use XML Escape?

No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.

What does XML Escape do?

XML Escape replaces the five characters that have a meaning in XML with the five entities every XML parser knows: &amp; &lt; &gt; &quot; &apos;. The result is safe in element text and in attribute values in either kind of quotes.

How does XML Escape work?

Each of these characters is replaced; all other characters are copied unchanged.

Are there any limits I should know about?

Escaping > is optional in XML except after ]]; it is escaped anyway so the output is safe everywhere. For HTML, use HTML Escape, which writes &#39; for the apostrophe.

Is there a size limit?

There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.

Does it work on phones, and is it free?

Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.