The XML formatter indents nested elements so the structure is easy to read. When an element mixes text and tags (mixed content, such as <p>Hello <b>world</b></p>) or declares xml:space="preserve", its content is kept exactly as is so the meaning does not change.
For security, documents with a DOCTYPE are rejected: there are no external entities or expansions to process.
How to use it
- Paste the XML or open a local file.
- Pick the indentation.
- Press Run and copy or download the result.
Example
<?xml version="1.0" encoding="UTF-8"?><catalog><book id="b1"><title>Guía de ejemplo</title><price currency="EUR">19.90</price></book><note>Texto <b>mixto</b> conservado</note></catalog> <?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="b1">
<title>Guía de ejemplo</title>
<price currency="EUR">19.90</price>
</book>
<note>Texto <b>mixto</b> conservado</note>
</catalog>
Limitations
- No DTDs or user-defined entities; only < > & ' " and numeric references.
- Whitespace between elements is normalized.
- Attributes are separated by one space and keep their original quotes.
FAQ
- Why is my XML with a DOCTYPE rejected?
- DTDs can declare entities that read files or URLs (XXE) or expand exponentially. This tool never processes them.
- Does it change my text content?
- No: each element’s text is kept; only whitespace between elements without mixed content is added or removed.