XML escape tool
Paste the text you want to place in an XML file and choose all five characters or only the three needed in text.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter text and what to escape.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
Each character is replaced by its standard entity: & to &, < to <, > to >, " to " and ' to '. The replacement runs in one pass character by character, so nothing is escaped twice within a run.
Example
Inputs: What to escape = All five (attributes and text). Result: Escaped text: شركة "النخبة" & أبناؤه <فرع جدة>; Characters replaced: 5.
شركة "النخبة" & أبناؤه <فرع جدة>
شركة "النخبة" & أبناؤه <فرع جدة>
Limits and caveats
- Text that is already escaped gets escaped again, so & becomes &amp;.
- Characters not allowed in XML 1.0, such as control codes, are not converted, remove them first.
Questions about this tool
When do I need to escape " and '?
When the text goes inside a quoted attribute value. Element text only needs & and <, with > added for safety.
Do Arabic letters need escaping?
No, Arabic letters are allowed directly in UTF-8 XML. Only the five special characters need entities.
How is this different from CDATA?
A CDATA section keeps text raw without escaping, but it cannot be used in attributes or hold ]]>, while escaping works everywhere.
