XML Escape

Escape and unescape XML special characters (&, <, >, ", ').

Input Text
Result

Safely Embed Text Inside XML Without Parser Errors

Characters like ampersands and angle brackets break XML parsing when used inside element content. This tool escapes them to their XML entity equivalents instantly, preventing injection issues and ensuring your XML document remains well-formed and parseable.

XML Entity Escaping

Why Use This Tool?

Prevent XML Parse Errors

Unescaped special characters cause XML parsers to throw errors. Escape them first to guarantee well-formed XML every time.

Escape & Unescape

Both directions in one tool — convert text to XML entities and reverse XML entities back to plain readable text.

All Five Entities Covered

Handles all five required XML entities: &amp;, &lt;, &gt;, &quot;, and &apos; — covering both element content and attribute values.

100% Private

All escaping runs locally in your browser. Your text content is never sent to or stored on any server.

How this XML Escape works

This character utility escapes special characters in XML strings to prevent syntax errors or injection issues. It replaces characters like <, >, &, ", and ' with their corresponding XML entities (<, >, &, etc.). This is crucial when embedding text content inside XML tags to ensure the parser treats it as data rather than markup. It also supports unescaping for reversing the process.

How to use this XML Escape

1

Paste Your Text

Paste the text content that contains special characters you need to embed inside XML tags.

2

Escape

The tool replaces <, >, &, ", and ' with their XML entity equivalents so the parser treats them as data, not markup.

3

Copy and Embed

Copy the escaped string and safely embed it inside your XML elements or attribute values.

Example Usage

Escape a string containing comparison operators and an ampersand for safe embedding inside an XML element.

Input
Price: 5 < 10 & discount > 0, use "promo" code
Output
Price: 5 &lt; 10 &amp; discount &gt; 0, use &quot;promo&quot; code

Frequently Asked Questions

Which characters need to be escaped in XML?
The five characters that must be escaped are: & (ampersand), < (less-than), > (greater-than), " (double quote in attributes), and ' (single quote in attributes). Of these, & and < are the most critical.
What are the XML entity replacements?
& becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, and ' becomes &apos;. These entities are defined in the XML specification and recognized by all XML parsers.
Can I unescape XML entities back to plain text?
Yes. The tool supports both escaping (text to entities) and unescaping (entities back to plain text), letting you reverse the process when you need to read or edit the original content.
Do I need to escape content inside a CDATA section?
No. Content wrapped in a CDATA section (<![CDATA[...]]>) is treated as plain text by the XML parser, so special characters inside CDATA do not need to be escaped.
Is this XML Escape tool secure?
Yes. All escaping runs entirely in your browser. Your text content is never sent to or stored on any server.

Related Tools

The XML Escape is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.

Featured On

CodeItBro - Free dev tools + practical guides to help you ship faster | Product HuntCodeItBro - Free Online Developer Tools badgeCodeItBro badge