Convert escaped XML entities like <, >, &, ", ' back to their original characters. Ideal for cleaning XML logs, API responses, and escaped database fields.
XML defines five predefined entities to represent characters that have special meaning in markup. When you see text like <message>, it is an escaped representation of the original <message>. Decoding (or unescaping) reverses this process, turning the entity references back into the actual characters so that the XML becomes human‑readable and processable.
| Entity | Decodes to | Description |
|---|---|---|
<
|
<
|
Less‑than sign |
>
|
>
|
Greater‑than sign |
&
|
&
|
Ampersand |
"
|
"
|
Double quote |
'
|
'
|
Apostrophe / single quote |
Numeric entities (e.g., ©) and other custom entities are not decoded by this tool — only the five standard XML entities, as defined in W3C XML 1.0 §4.6.
A SOAP web service returns faults with escaped XML inside the <faultstring> element. For example: <error>Invalid token & request ID</error>. Using this decoder, developers can quickly see the actual error: <error>Invalid token & request ID</error>. This accelerates debugging without manual replacement.
The decoder scans the input string and replaces each known entity with its corresponding character. The order of replacement is important: ampersand (&) is replaced last to avoid interfering with other entities (e.g., < contains an ampersand). The algorithm follows:
< → <
> → >
" → "
' → '
& → &
This ensures that even nested or double‑encoded entities are correctly resolved. All replacements are performed using JavaScript’s global string replace, which is efficient for text up to several megabytes. No external libraries are required.
Performance note: For typical XML fragments under 500 KB, decoding completes in under 20 ms. Larger texts (up to 10 MB) may take a few seconds but remain fully functional within the browser’s main thread.
| Situation | Recommendation |
|---|---|
Your text contains numeric entities like <
|
Use a full XML parser or a tool that supports numeric entity expansion. This decoder leaves them unchanged. |
| You have custom DTD entities | Only the five predefined entities are supported. Custom entities require a full XML processor. |
The text is already plain (no & followed by known entity names)
|
Decoding will have no effect — output will be identical to input. |
Example transformation:
Input (escaped): <root>Value & 5 < 10</root>
Output (decoded): <root>Value & 5 < 10</root>
<![CDATA[ ... ]]>) is escaped, the decoder will unescape the brackets and exclamation marks, restoring the CDATA declaration. However, the content inside CDATA is not parsed further; if it contains entities, they will be decoded as usual because the decoder works on the entire string. This is intentional and matches generic text decoding.
&lt; → <. Click Decode again to turn < into <. This allows you to progressively unescape deeply encoded content.
decodeXML() function in your own projects freely — there are no restrictions.