XML Entity Escaper/Unescaper

Escape the 5 XML special chars amp, lt, gt, apos, and quot

Ad placeholder (leaderboard)

XML is far stricter than HTML about entities: it predefines only five. This tool escapes those five characters so your text is well-formed inside XML elements and attributes, and unescapes them back to plain characters.

How it works

Escaping replaces the ampersand first, then the remaining four characters, so no sequence is double-processed:

& -> &
< -> &lt;
> -> &gt;
' -> &apos;
" -> &quot;

Unescaping reverses these five named references and also expands numeric references such as &#10; and &#xA;, which XML permits, while leaving any unknown reference untouched so no data is lost.

Tips and notes

In element content you strictly only need to escape & and <, but escaping all five is harmless and portable, so this tool does it by default. Inside an attribute delimited by double quotes you must escape the double quote; inside one delimited by single quotes you must escape the apostrophe. Never use HTML-only entities like &nbsp; in plain XML — they make the document fail to parse. If you need those, declare them in a DTD or use a numeric reference instead.

Ad placeholder (rectangle)