XML tools

XML escapefor the receiving context

Choose a text node or an attribute value before escaping.

XML escape

Current text

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.

Ctrl/Cmd+Enter: Escape textCtrl/Cmd+Shift+Enter: Unescape string

Enter text or load an example. Empty text can be converted.

0 UTF-16 units

Conversion options

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.

View original

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.

Why use XML escape?

Keep whitespace meaningful

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.

The same quoted value follows two paths, with quotation marks protected only in the attribute path.

Keep batch records separate

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.

Two separate record cards remain separate while a restored newline expands the content of the first card.

Choose context and inspect the boundary

01

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.

02

Convert only when you choose

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.

03

The editor holds the full text

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.

References, locations and record values

Five named entities

XML escape keeps XML entities distinct from HTML names. Decoding recognizes amp, lt, gt, quot and apos, with exact case and a required semicolon.

Numeric character references

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.

Locate rejected input

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.

Content strings and explicit limits

A value, not a document
XML escape does not validate element names, tag nesting, schemas or attribute syntax. Decoding retains ordinary raw angle brackets and quotes; it checks references, not the document around them.
One layer, five built-in names
< becomes < in one run. Unknown HTML names such as  , custom DTD entities, bare ampersands and incomplete references fail. No recursive decoding or external entity resolution occurs.
XML 1.0 character range
NUL, forbidden C0 controls, isolated surrogates and U+FFFE/U+FFFF are rejected, including numeric references to them. Legal supplementary characters remain intact; U+1FFFE is allowed by XML 1.0.
Whitespace is not normalized here
Encoding protects CR, and in attribute mode TAB/LF as well. Decoding preserves raw whitespace. The attribute guarantee concerns CDATA-type attributes; DTD tokenized attributes may still normalize spaces.
Lines are records in batch mode
Records split on the original CRLF, CR or LF and keep empty lines, a trailing empty record and the separators. The editor shows the current text joined with those separators. Decoding 
 can add a newline inside a record. TXT cannot recover the boundaries; the JSON report’s records keep each input, output and separator.
Bounded local conversion
The first input is limited to 1,048,576 UTF-16 units. Output and further processing of a generated document are limited to 6,291,456. Per-line mode allows 10,000 records, and a JSON report allows 16,777,216 units. Oversized work fails as a whole. There is no file import, network fetching, CDATA wrapper, forced ASCII or silent deletion of illegal characters.

XML escape questions

Which entity names does XML recognize by default?

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.

Can HTML entity names also be used in XML?

Not generally. HTML has many built-in names that XML does not. For a nonbreaking space, use a literal valid Unicode character or &#160; rather than &nbsp;. Custom declarations are outside this tool.

Which situations require XML character escaping?

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.

When is a CDATA block preferable to escaping?

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.

Will malformed references stop an XML parser?

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?

Try a representative value

Use XML escape with an ampersand, quotes and a line break, then compare text and attribute output.