XML Formatter & Beautifier
Turn compressed or messy XML into a cleanly indented document that is easy to read and review.
Processed locally in your browser/ Your data stays in your browser.
What is XML Formatter & Beautifier?
XML is used for configuration files, RSS and Atom feeds, SVG, SOAP messages, Office documents and many enterprise formats. It often arrives on a single line or with inconsistent indentation, which hides the structure.
This formatter first checks that the document is well-formed, then re-indents it. It keeps the XML declaration, attributes, comments and CDATA sections, and it leaves mixed content such as <p>Hello <b>world</b></p> untouched because whitespace is meaningful there. Entities are never expanded or fetched, so even hostile documents are safe to paste.
How does it work?
- Paste your XML or open an .xml file.
- Choose 2 spaces, 4 spaces or a tab, and decide whether to keep comments.
- If the XML is not well-formed, read the error message: it includes the line and column.
- Copy the result or download formatted.xml.
Common use cases
- Reading a SOAP response or an RSS feed returned on one line.
- Cleaning a pom.xml, web.config or Android layout before committing it.
- Making an XML export from an ERP or CMS reviewable in a diff.
- Checking the nesting of a hand-written XML snippet.
Examples
Try this input in the tool above:
<?xml version="1.0" encoding="UTF-8"?><catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><price currency="USD">44.95</price></book><!-- next entry --><book id="bk102"><author>Ralls, Kim</author><title>Midnight Rain</title><price currency="USD">5.95</price></book></catalog>
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<price currency="USD">44.95</price>
</book>
<!-- next entry -->
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<price currency="USD">5.95</price>
</book>
</catalog>Privacy
XML Formatter & Beautifier runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Only whitespace between elements is changed, but formatting can still alter documents where whitespace is significant (xml:space="preserve", pre-formatted text inside text-only elements). DTD validation is not performed.
Frequently asked questions
Does the formatter change my data?
No. Element names, attributes, comments, CDATA and text are kept. Only the whitespace between elements is normalised. Mixed content is preserved exactly.
What happens with a DOCTYPE that declares entities?
The document is formatted, but entities are never expanded and a warning explains the “billion laughs” and XXE risk of such documents.
Why does it refuse my XML?
The document must be well-formed: one root element, properly nested and closed tags, quoted attribute values. The error message shows the line and column of the first problem.
Related tools
XML Validator
Find out whether your XML is well-formed and see precisely where it breaks.
JSON & Data
XML Minifier
Compress an XML document by removing the whitespace between elements and, optionally, comments.
JSON & Data
XML to JSON Converter
Turn an XML document into JSON, keeping attributes, repeated elements and text content in a predictable structure.
JSON & Data
JSON to XML Converter
Turn a JSON document into well-formed XML with control over the root element, attributes and formatting.
JSON & Data
XML Escape
Make any text safe to place inside an XML element or attribute value.
JSON & Data
HTML Formatter
Paste minified or messy HTML and get clean, consistently indented markup you can read and diff.
Developer Tools
JSON Formatter & Beautifier
Turn a minified or messy JSON document into readable, consistently indented text, with a precise error message if the JSON is invalid.
JSON & Data