XML Escape and Unescape Tool

Escape XML special characters for text content or attribute values, or decode named entities and numeric character references back into readable text. Processing happens locally in your browser.

Processed locally in your browser

Input is processed as text. The tool does not load DTDs or resolve external entities.

The selected context controls whether quotes or apostrophes are escaped.

Advanced options

Required XML syntax characters are still escaped according to context.

Optional normalization may change how some Unicode characters are represented.

Escape mode treats input as plain text, so existing entity references may be escaped again.

Escape or unescape XML online

This XML entity encoder escapes special XML syntax characters for text nodes, double-quoted attributes or single-quoted attributes. It can also decode XML entities, decimal character references and hexadecimal character references. The converter treats all input as text, so it does not validate complete XML documents, load DTDs, resolve external entities or fetch external resources.

XML escape examples

XML markup escaped as text:

<note author="Ana">Café & tea isn't ready</note>

Escaped in text-content mode:

&lt;note author="Ana"&gt;Café &amp; tea isn't ready&lt;/note&gt;

Text-content example:

Tom & Ana < Developers
Tom &amp; Ana &lt; Developers

Double-quoted attribute example:

Ana "Admin" & Team
Ana &quot;Admin&quot; &amp; Team
<user title="Ana &quot;Admin&quot; &amp; Team"/>

Single-quoted attribute example:

Ana's Team & Support
Ana&apos;s Team &amp; Support
<group name='Ana&apos;s Team &amp; Support'/>

XML text content vs attribute values

Text nodes require escaping ampersands and less-than signs. This tool also escapes greater-than signs as &gt; for predictable output. Double-quoted attributes require double quotes to be escaped; single-quoted attributes require apostrophes to be escaped. Escaping both quotation styles in every context is valid XML but unnecessarily verbose, so the context selector produces minimal context-aware output.

CharacterText contentDouble-quoted attributeSingle-quoted attribute
&&amp;&amp;&amp;
<&lt;&lt;&lt;
>&gt;&gt;&gt;
"Preserved&quot;Preserved
'PreservedPreserved&apos;

XML special characters and predefined entities

XML defines five predefined named entities. HTML has many more named entities, but those are not automatically available in XML unless a document defines them separately.

CharacterEntityTypical use
&&amp;Required before literal ampersands
<&lt;Required before literal less-than signs
>&gt;Valid and useful for consistent escaping
"&quot;Required in double-quoted attributes
'&apos;Required in single-quoted attributes

Decimal and hexadecimal character references

Decimal references use &#NUMBER; and hexadecimal references use &#xHEX;. Both represent Unicode code points and require a terminating semicolon. Hexadecimal digits are case-insensitive when decoding, and this tool outputs uppercase hexadecimal digits for consistency. For example, &#233; and &#xE9; both represent é, while &#x1F600; represents 😀.

How to use the XML entity converter

  1. Paste XML text, an attribute value, or escaped entity text into the input field.
  2. Select Escape or Unescape.
  3. Choose text content, a double-quoted attribute, or a single-quoted attribute.
  4. Optionally select numeric-reference output or Unicode normalization.
  5. Process the text, then copy or download the result.

Existing entities and double escaping

Escape mode treats input as plain text. Existing ampersands are escaped, so &amp; becomes &amp;amp;. Use Unescape mode first when the goal is to decode existing entities. This tool does not attempt to resolve custom entities declared in a DTD.

Invalid XML entities and character references

Unknown named entities and malformed numeric references are preserved. Invalid Unicode code points, surrogate code points and XML-invalid characters are not decoded from numeric references. The tool reports these problems instead of silently deleting content, and no external entity resolution occurs.

Privacy and local processing

This tool processes text with JavaScript directly in your browser. Your input is not submitted to UnicodeNow servers. The converter does not load DTDs, resolve external entities or fetch external resources.

Frequently asked questions

How do I escape special characters in XML?

Choose Escape, select the XML context, and process the text. Ampersands, less-than signs and other context-required characters are converted to XML-safe entity references.

Which characters must be escaped in XML?

Ampersands and less-than signs must be escaped in text. Double-quoted attributes also need double quotes escaped, and single-quoted attributes need apostrophes escaped.

How do I escape an XML attribute value?

Select Double-quoted attribute or Single-quoted attribute before escaping. The tool then escapes the quote character that matches the delimiter and preserves the other quote style.

What is the difference between &lt; and &#60;?

Both represent the less-than character. &lt; is one of XML's five predefined named entities, while &#60; is a decimal numeric character reference.

How do I decode XML entities?

Choose Unescape to decode the five predefined XML entities plus valid decimal and hexadecimal numeric character references.

Will existing XML entities be escaped again?

Yes in Escape mode. Input is treated as plain text, so &amp; becomes &amp;amp;. Use Unescape first when the goal is to decode existing entities.

Does this tool resolve external XML entities?

No. It treats input as text and does not load DTDs, resolve external entities, fetch URLs or validate XML schemas.

Is my XML input sent to a server?

No. This browser-local converter processes text with JavaScript and does not submit your input to UnicodeNow servers.

Related tools

For HTML-specific named entities, use the HTML Entity Encoder and Decoder. For Unicode code points and numeric references, use the Unicode Escape Converter. For structured JSON strings, use the JSON Escape and Unescape tool.

PHP Escape and Unescape

Escape and unescape PHP-style single and double quoted strings.

DeveloperProcessed locally

Unicode Escape Converter

Convert text to and from Unicode escape sequences and numeric entities.

DeveloperProcessed locally

Related guides

Unicode vs UTF-8

Unicode defines characters and code points. UTF-8 encodes those code points as bytes for files, databases, web pages, APIs and network messages.