ToolLineup

XML Escape / Unescape

This XML escaper replaces the five characters XML reserves — ampersand, less-than, greater-than, double quote and apostrophe — with their entity forms, so any text can sit inside an element or an attribute without breaking the document. Unlike HTML, which defines over a thousand named entities, XML predefines exactly those five: every other character must be written as a numeric reference such as © or ©. Unescaping understands both numeric forms alongside the five names. Everything runs in your browser.

How it works

Replaces the five characters XML gives special meaning — & < > " and the apostrophe — with their entity forms, so the text can sit inside an element or an attribute without breaking the document.

XML predefines only those five entities. Unescaping also understands numeric references such as &#169; and &#xA9;, which is how every other character has to be written.

Escaping runs entirely in your browser — nothing you paste is sent to a server.

Plain text input
Paste the text to escape…
XML-escaped output

0 characters in · 0 characters out

How to escape XML

  1. Paste your text into the input on the left.
  2. The escaped result appears on the right, ready to drop into an element or attribute.
  3. Switch to Unescape to turn entities back into plain text.

The five predefined entities

CharacterEntityWhy it matters
&&amp;Starts every entity, so it must be escaped first
<&lt;Would otherwise open a tag
>&gt;Closes a tag
"&quot;Ends a double-quoted attribute
'&apos;Ends a single-quoted attribute

Everything else needs a numeric reference

Unlike HTML, which defines well over a thousand named entities, XML predefines exactly those five. A copyright sign has no &copy; in plain XML — it is written as &#169; or &#xA9;. Unescaping here understands both numeric forms as well as the five names.

Common use cases

  • Putting user-supplied text into an XML document without breaking it.
  • Embedding a code sample or a URL with query parameters inside an element.
  • Reading escaped text back out of an export.

Frequently asked questions

Which characters does XML require escaping?

Five: the ampersand, less-than, greater-than, double quote and apostrophe. The ampersand must be handled first, because it begins every entity — escaping it last would double-escape the ones already inserted.

Why does XML have so few named entities compared to HTML?

HTML defines well over a thousand names as a convenience; XML deliberately predefines only five and expects everything else as a numeric character reference, which keeps parsers simple and avoids depending on an external DTD.

How do I write a copyright sign in XML?

As a numeric reference — &#169; in decimal or &#xA9; in hexadecimal. There is no &copy; in plain XML, and using it will make the document fail to parse.

Is this the same as HTML entity encoding?

Not quite. HTML escaping can use hundreds of named entities that XML does not recognise, so text escaped for HTML may not be valid inside an XML document.

Is my text uploaded anywhere?

No. Escaping runs entirely in your browser.

Related tools