XML Escape
XML escape and unescape online. Encode or decode &, <, >, and quotes for XML text. Free XML encoder in your browser.
Input
Output
Features
- Escape & < > " ' for XML text or attributes
- Unescape named and numeric character references
- Switch between escape and unescape
- Preview the result immediately
- Copy the safe string into a document or code
- No server round-trip
Common Use Cases
- Put a URL with query string into an XML text node
- Embed a snippet of code in a docbook or config value
- Undo &amp;lt; chains from double-escaped logs
- Prepare attribute values that contain quotes
- Explain to a teammate why Tom & Jerry broke the parser
The five characters XML reserves
In character data, & and < must be escaped. > is often escaped for symmetry. In attributes, quotes need " or ' depending on the delimiter.
Numeric references like © and © decode to Unicode. Unescape applies named entities we listed plus numeric forms. HTML-only names like are not XML unless a DTD defined them.
Examples
Invalid - Needs escape
Tom & Jerry <show> Valid - Escaped
Tom & Jerry <show> Valid - Numeric entity
AFrequently Asked Questions
Should I escape inside CDATA?
No. CDATA is raw except for the sequence ]]>. Do not double-escape there.
Is this HTML entity encoding?
Close, but HTML has a much larger named-entity list. XML without a DTD only guarantees & < > ' " plus numeric forms.
Tips
- Escape first, then wrap in tags. Do not escape the tags themselves.
- If you see &amp;amp;, the value was escaped more than once. Unescape until it looks like the original text.