Shiklo Tools
PDF40
Image20
Calculators & Converters25
Text & Writing13
Developer26
Video14
Audio14
Document14
Data & Spreadsheet12
Web & SEO9
OCR & Scanning5
Archive & File12
Security & Privacy23
Health & Medical29
QR & Barcode5

XML Escape / Unescape

Escape text for XML (& < > " ') or turn XML entities and character references back into plain text.

Five characters have special meaning in XML: the ampersand, the less-than and greater-than signs, and double and single quotes. Text that contains them — a product name like Tom & Jerry, a formula with a comparison, or a description with quotation marks — has to be escaped before it goes into an XML document, an RSS feed, an SVG file, a sitemap or a SOAP message, or the document becomes invalid.

This tool escapes text for XML in one step, either for element content or for attribute values, and also works in reverse, turning entities such as & and numeric character references such as © back into the characters they stand for. It warns about control characters that XML does not allow at all, and keeps entities it doesn't know so nothing is silently lost. Everything runs in your browser.

How to use XML Escape / Unescape

  1. Paste the text or XML, open a file, or press Sample.
  2. Choose Escape or Unescape.
  3. When escaping, choose attribute values or element text.
  4. Copy the result or download it.

Features

  • Escapes &, angle brackets and, for attributes, both quote marks.
  • Unescapes the five XML entities and decimal and hex references.
  • Unknown entities are kept and listed.
  • Refuses control characters XML 1.0 forbids.
  • Live conversion as you type.
  • Runs in your browser; nothing is uploaded.

Where escaping is needed

Any text that goes into XML from outside — product names and descriptions in shopping feeds, titles in RSS and Atom feeds, captions in SVG images, values in Android and .NET resource files, entries in sitemaps, fields in SOAP and other XML APIs, and configuration values in XML-based files — must be escaped. A single unescaped ampersand makes the whole document invalid, and feed readers, search engines and apps then reject it entirely. Programming languages have built-in functions for this, and you should use them in code; this tool is for quick manual jobs, checking a value, and decoding entities you find in existing files.

The five XML entities

XML defines exactly five named entities. Every XML parser understands them, unlike HTML names such as   or ©, which XML does not know unless a DTD declares them.

CharacterEntityMust be escaped
& (ampersand)&Always
less-than sign<Always
greater-than sign>Recommended, required after ]]
" (double quote)"In attribute values quoted with double quotes
' (apostrophe)'In attribute values quoted with single quotes

Element text or attribute values

Inside element content only the ampersand and the less-than sign strictly need escaping, and the greater-than sign is escaped too for safety; quotes can stay as they are, which keeps the text readable. Inside attribute values the quote used to delimit the value must also be escaped. Choose Attribute values to escape both quote marks so the result is safe whichever quote the attribute uses, or Element text to leave quotes alone.

Unescaping

Unescape turns &, <, >, " and ' back into characters, and also numeric character references in decimal (é) or hexadecimal (é) form, which can represent any Unicode character. Other named entities — common when HTML is pasted as XML — are not part of XML, so they are left unchanged and listed, rather than guessed. To decode HTML entities such as é or  , use the HTML Entity Encoder instead.

Characters XML cannot contain

XML 1.0 forbids most control characters (code points below 32 other than tab, line feed and carriage return), and the non-characters U+FFFE and U+FFFF, even when escaped. They sometimes appear in text copied from old systems or binary data. If your text contains one, the tool reports the character and its position instead of producing XML that parsers would reject. Remove it, or encode the data another way, such as Base64.

Frequently asked questions

Which characters must be escaped in XML?

The ampersand and the less-than sign always; quotes inside attribute values; the greater-than sign is commonly escaped too.

How do I escape an ampersand in XML?

Write it as &. The tool does it for you.

Is   valid in XML?

No. Use the numeric reference   instead.

Can it convert entities back to text?

Yes. Choose Unescape.

What about CDATA sections?

CDATA can hold unescaped text, but escaping works everywhere, including attributes.

Is my data uploaded?

No. Conversion happens in your browser.

Related tools