How to use the xml unescape
- Paste your escaped XML markup into the text area.
- The tool immediately decodes all entities and checks for well-formedness.
- If valid, the decoded XML appears in the output box below.
- If an error is found, the exact line and column are reported so you can fix it.
How XML entity decoding works
An xml unescape operation reverses the encoding applied when special characters are stored inside XML. The five predefined entities are replaced directly: & becomes &, < becomes <, > becomes >, " becomes ", and ' becomes '.
Numeric character references use the format &#digits; for decimal or &#xhex; for hexadecimal. For example, € resolves to the Euro sign because 8364 is its Unicode code point. Hexadecimal references like € produce the same character.
The parser reads through the document character by character. When it encounters an ampersand outside a CDATA block, it collects characters until the semicolon, looks up the reference, and substitutes the corresponding character into the output stream.
Well-formedness checking
Beyond simple string replacement, this tool includes a hand-written XML tokenizer that verifies the document is well-formed before returning the result. It checks that every opening tag has a matching closing tag, that attribute values are properly quoted, and that special constructs like comments and processing instructions are correctly terminated.
If the parser finds a problem, it stops and reports the line and column number where the first error occurred. This makes it much easier to locate broken markup than a generic failure message. The tokenizer handles elements, attributes, text nodes, CDATA sections, comments, and processing instructions.
Note that DOCTYPE declarations and external entity definitions are intentionally not supported. If your document relies on a DTD to define custom entities, those references will be flagged as errors. Only the five standard XML entities and numeric character references are recognized during the xml unescape process.
Common XML entities reference
The following table lists the predefined XML entities and a few common numeric references you might encounter when working with escaped data.
| Entity | Character | Description |
|---|---|---|
& | & | Ampersand |
< | < | Less-than sign |
> | > | Greater-than sign |
" | " | Double quotation mark |
' | ' | Apostrophe / single quote |
| (newline) | Line feed |
| (carriage return) | Carriage return |
  | (non-breaking space) | No-break space |
CDATA sections and raw content
CDATA sections provide a way to include blocks of text that should not be parsed for markup or entities. A CDATA block starts with <![CDATA[ and ends with ]]>. Inside these delimiters, characters like < and & are treated as literal text rather than the start of tags or entity references.
When you perform an xml unescape on a document containing CDATA sections, the content inside the CDATA block is preserved exactly as written. The delimiters themselves remain in the output so the resulting document stays structurally valid. This is particularly useful when handling embedded scripts or code snippets that naturally contain many angle brackets and ampersands.
If you need to strip the markup entirely and extract only the human-readable content, consider using a dedicated xml to text converter instead. That tool removes all tags and returns just the text nodes.
Worked examples
| Example | Input | Result |
|---|---|---|
| Basic entities | Escaped XML: <msg>Tom & Jerry <3></msg> | <msg>Tom & Jerry <3></msg> |
| Numeric references | Escaped XML: <data>AB€</data> | <data>AB€</data> |
| CDATA section | Escaped XML: <script><![CDATA[if (a < b && c > d) {}]]></script> | <script>if (a < b && c > d) {}</script> |
| Attributes with quotes | Escaped XML: <item name="O'Brien" desc="A & B"/> | <item name="O'Brien" desc="A & B"/> |
FAQ
What does xml unescape mean?
It means converting encoded XML entities like & and numeric references like A back into their original characters. This restores the readable form of data that was escaped for safe inclusion in an XML document.
Which entities are supported?
The five standard XML entities (amp, lt, gt, quot, apos) and both decimal and hexadecimal numeric character references are supported. Custom entities defined in a DTD are not resolved.
Why does the tool report an error instead of just replacing entities?
Replacing entities in malformed XML can produce unpredictable results. By validating well-formedness first, the tool ensures the output is structurally sound and highlights exactly where the input is broken.
Are CDATA sections decoded?
No. Content inside a CDATA section is already literal text, so entities in it are not decoded. Inside an element the <![CDATA[ and ]]> markers are removed and the content is kept exactly as written; a CDATA section at the top level is left untouched.
Does this tool support DOCTYPE declarations?
No. DOCTYPE declarations and external entity definitions are not supported. Documents relying on them will trigger a parsing error at the DOCTYPE location.
Is my data sent to a server?
No. The entire parsing and decoding process happens locally in your browser. Nothing is uploaded anywhere.