Escape text for XML, which predefines only amp, lt, gt, quot and apos – everything else must be a numeric reference. Control characters that XML 1.0 forbids are escaped too.
Show calculation steps
Processed privately in your browser — nothing you paste is uploaded, logged or stored.
How to use the XML Entity Encoder
- Paste the text that needs to go inside an XML document.
- Keep attribute mode on when the text will sit inside an attribute value, so quotes are escaped too.
- Enable the non-ASCII option if the document may not reliably declare its encoding.
- Click "Encode for XML".
Frequently asked questions
Why does XML have only five named entities?
XML is deliberately minimal: amp, lt, gt, quot and apos are the only names defined by the specification. Everything else must either be a numeric character reference or be declared in a document type definition. HTML, by contrast, predefines hundreds of names.
Why are some invisible characters escaped automatically?
XML 1.0 forbids most control characters from appearing literally in a document, even though they are valid Unicode. Encoding them as numeric references keeps the document well-formed. This is a common source of parser errors when exporting data from databases.
Do I need to escape the greater-than sign?
Strictly it is only required in the specific sequence that ends a CDATA section, but escaping it always is the safer habit and costs nothing – so this tool escapes it consistently.