Select the destination
Text mode keeps quotation marks. Attribute mode escapes only the quote used by the surrounding attribute; it does not add the surrounding quotes or a tag.
XML tools
Choose a text node or an attribute value before escaping.
Escape turns source text into XML references; unescape restores one layer. Destination, quotes and per-line mode affect only the next action. A failure keeps the current text.
Enter text or load an example. Empty text can be converted.
0 UTF-16 units
Destination and quotes affect the next escape; per-line mode affects the next escape or unescape. None of them rewrite the current text. Text mode keeps quotes and writes CR as . Attribute mode also escapes the selected quote, tab and line feed. Batch separators stay literal. A decoded newline belongs inside its record; the JSON report keeps the boundaries.
First input: 1,048,576 UTF-16 units. Output and later processing of a generated document: 6,291,456. Per-line mode: 10,000 records. JSON report: 16,777,216 units. Pasting may normalize line endings.
Conversion stays in this browser; input is not uploaded. Undo history stays in this tab. Long documents limit how much history is kept.
XML escape is useful when an ampersand in a product name breaks a feed, or a quoted value must fit inside an attribute. The destination matters: text content and quoted attributes do not need identical replacements.
XML unescape restores one encoded layer. It reads entity references in a content string without parsing tags, loading a DTD or treating the input as a complete document.
XML escape encodes a carriage return as a numeric reference. Attribute mode also protects tabs and line feeds, plus the selected quote. This preserves values when inserted into ordinary CDATA-type attributes.
Restoring a numeric newline reference can create extra lines inside one record. The JSON report stores each input, output and original separator separately, so those new lines do not erase record boundaries.
Text mode keeps quotation marks. Attribute mode escapes only the quote used by the surrounding attribute; it does not add the surrounding quotes or a tag.
Nothing runs automatically. Click Escape text or Unescape string, or press Ctrl/Cmd+Enter to escape and Ctrl/Cmd+Shift+Enter to unescape. Options affect only the next action. A failure keeps the current text and does not add a successful history step.
Example and Clear start a new document and can be undone. Undo and redo cover edits, conversions, restoring the original, examples and clearing. Copy and download export the full current text. The JSON report matches only the latest successful conversion and keeps each record boundary.
XML escape keeps XML entities distinct from HTML names. Decoding recognizes amp, lt, gt, quot and apos, with exact case and a required semicolon.
Decimal references such as A and hexadecimal references such as A both restore A. The hexadecimal prefix must use lowercase x; its digits may use either case.
XML special characters can be encoded, but forbidden XML 1.0 characters cannot be repaired by spelling their numeric value. The first error reports the original line and UTF-16 column; the whole run fails.
The five predefined names are amp, lt, gt, quot and apos. They represent &, <, >, double quote and apostrophe. Names are case-sensitive; this XML escape tool rejects other names instead of guessing a definition.
Not generally. HTML has many built-in names that XML does not. For a nonbreaking space, use a literal valid Unicode character or   rather than . Custom declarations are outside this tool.
Escape a data value before inserting it into markup: at least ampersands and less-than signs need attention. The tool also encodes greater-than signs to avoid a literal ]]> sequence, and offers context-specific quote and whitespace handling.
CDATA can hold text with many angle brackets, but it cannot appear inside an attribute and cannot contain its own ]]> terminator. This page does not generate CDATA sections.
A conforming XML parser reports malformed or undeclared references. This decoder also rejects unknown or incomplete references, but a successful result does not certify that the surrounding XML document is valid.
Found an unexpected result?
Use XML escape with an ampersand, quotes and a line break, then compare text and attribute output.