XML Formatter
Pretty-print and validate XML documents.
🔒 Runs entirely in your browser — nothing is uploaded.
Valid XML
How XML Formatter works
How does the XML formatter work?
It parses your input with the browser's built-in DOMParser and checks for a <parsererror> node to catch malformed XML. It then walks the resulting DOM tree recursively, indenting each element by depth (2 or 4 spaces), self-closing elements that have no children, and putting elements with only a single text child on one line.
What is it useful for?
It is useful for pretty-printing a minified XML response - a SOAP payload, RSS feed, or config export - so the nesting and structure are actually readable.
Does it preserve the XML declaration and DOCTYPE?
No - the serializer only handles text, comment, and element nodes, so an <?xml version="1.0"?> declaration or a DOCTYPE at the top of the document is silently dropped from the formatted output. Add it back manually if your final file needs it.