XML Formatter
Format, validate, and minify XML data in one click, entirely in your browser.
Related tools
About this tool
XML still quietly runs a large share of the web's plumbing — SOAP APIs, RSS and Atom feeds, Android and Java configuration files, sitemaps, SVG markup, and countless legacy enterprise systems all exchange data as XML. Unlike JSON, XML documents pulled from an API or a log file are often returned with no line breaks at all, or with inconsistent indentation left over from a hand edit, which makes it hard to see where one element ends and the next begins. A formatter's job is to turn that wall of angle brackets into a properly nested, readable tree, or to do the reverse and strip it back down to its smallest valid form.
This tool runs entirely in your browser, using the DOMParser and XMLSerializer APIs built into every modern browser — the same primitives a browser uses internally to parse an XML document, exposed for your own use. Nothing you paste is sent to a server: the parsing, reformatting, and validation all happen locally, which matters because XML payloads frequently carry internal service configuration, SOAP request/response bodies with account details, or other content you wouldn't want to hand to a random web backend.
Formatting ("Format") re-indents the document so every nested element lines up under its parent, keeps short text-only elements on a single line for readability, and collapses genuinely empty elements down to a single self-closing tag instead of a separate open and close pair. Minifying ("Minify") does the opposite — it strips every whitespace-only text node between tags to produce the smallest valid document, which is exactly what you want before sending a SOAP request over the wire or embedding XML inside another file where size matters. Both directions parse and re-serialize the same DOM tree, so the underlying element structure, attributes, and text content are never altered — only the whitespace around them is.
Because parsing goes through a real XML parser rather than a handful of regular expressions, the tool also acts as a validator: a missing closing tag, mismatched open/close tags, or more than one root element is reported as a clear parse error instead of silently producing broken or misleading output. That immediate feedback is often the fastest way to track down a hand-edited config file that a build system suddenly refuses to load, or a malformed response coming back from an old SOAP endpoint.
Once you have a formatted or minified result, copy it directly, or use the “Send to” button to hand it straight to another tool in this toolbox — useful, for instance, when you want to check the length of a minified payload before embedding it somewhere with a size limit.
Frequently asked questions
What does formatting XML actually change? expand_more
Only whitespace and indentation — every element, attribute, and text node is preserved exactly. Formatting adds indentation and line breaks for readability; minifying removes all non-essential whitespace between tags to shrink the payload.
Will this tool tell me why my XML is invalid? expand_more
Yes. If the document can't be parsed — a missing closing tag, mismatched tags, or more than one root element — the tool reports the parser's error message instead of guessing, which usually points straight at the problem.
Is it safe to paste sensitive data, like a SOAP request with real account details? expand_more
The formatting and validation happen entirely in your browser using the native DOMParser — nothing is uploaded to a server — so it's safe to use with data you wouldn't want to send elsewhere.
Does this tool work offline? expand_more
Yes, once the page has loaded. All parsing and formatting happens locally, so no internet connection is required afterward.
Does it support XML comments and processing instructions like the XML declaration? expand_more
Yes. The XML declaration at the top of the document, and any comments it contains, are preserved when formatting or minifying — neither is stripped out.