Encoding
XML Entities Encode/Decode
Encode and decode XML entities — the 5 predefined ones (ampersand, angle brackets, apostrophe, quote) and numeric character references.
Unlike HTML, XML strictly requires escaping five special characters (&, <, >, ', "), or the document is considered invalid. This tool encodes and decodes those entities, as well as numeric character references.
How to use it
- Encode: paste text and the five reserved characters get replaced with their matching entities (&, <, >, ', ").
- Decode: paste XML containing entities to get plain text back.
- Numeric character references (& or &) are supported too, for characters outside the standard five.
Common uses
- Preparing user text for insertion into an XML document (an RSS feed, a SOAP request, a config file).
- Debugging why an XML parser rejects a document — often the cause is an unescaped ampersand or angle bracket inside the text.
- Decoding content received from an XML-based API to read it in its original form.
Things to keep in mind
XML parsers are much stricter than HTML: a single unescaped entity invalidates the entire document, not just one element.
CDATA sections (<![CDATA[...]]>) are an alternative to escaping for large blocks of text, letting you insert arbitrary content without replacing every special character individually.
Article about this tool: XML Entities: escaping characters in XML documents
Frequently asked questions
What are the 5 predefined XML entities?
XML only predefines five named entities: & (ampersand), < and > (angle brackets), ' (apostrophe), and " (quote). Anything beyond these needs a numeric character reference instead.
How is this different from HTML entity encoding?
HTML defines a much larger set of named entities (like or ©), while strict XML only recognizes the five predefined ones — any other special character in XML must use a numeric reference like © or ©.
When do I need to escape XML entities?
Escape characters like < > & ' " whenever they appear in text content or attribute values in an XML document, so the parser doesn't mistake them for markup and fail to parse the file.
What is CDATA and when should I use it instead of entities?
A <![CDATA[...]]> section lets you insert a block of text without escaping < and & — handy for large code or HTML fragments inside XML. The exception is the sequence ]]>, which closes CDATA and can't appear inside the section's own content.
Do all XML parsers handle invalid entities the same way?
No, and unlike browsers, which "forgive" mistakes in HTML, XML parsers are strict: a single unescaped ampersand or angle bracket makes the entire document invalid, and parsing stops with an error.