jsonecho

XML Escape

Paste your text and get it escaped for XML, ready to paste into code or data.

Loading the tool...

How to use XML Escape

  1. Paste or type the text you want to escape.
  2. Adjust the options if you need to.
  3. Copy the escaped result.

About XML Escape

XML has five predefined entities, and you have to use them whenever those characters appear in text or in an attribute value. An unescaped ampersand or angle bracket makes the whole document invalid, and a parser will refuse to read it at all, so there is no partial credit.

Escaping is easy to forget when you build XML by gluing strings together. Paste the raw text here and you get a version that is safe to drop between tags or inside an attribute.

What gets escaped

& becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &apos;.

Frequently asked questions

Do I have to escape the greater-than sign?

In most places it is allowed unescaped, except in the sequence ]]>. Escaping it everywhere is the safe habit and is what this tool does.

What is the difference between XML and HTML escaping?

Only the apostrophe. XML defines ' for it, HTML does not. Everything else is the same.

Can I use CDATA instead?

For a long block of text, yes: <![CDATA[ ... ]]> lets you skip escaping. It is not available inside attribute values.

What about characters that are not allowed in XML at all?

Most control characters (apart from tab, line feed and carriage return) cannot appear in XML 1.0, even escaped. They have to be removed.

More in Escape and Text

All tools →