XML Formatter, Beautifier and Validator
Format, validate and minify XML in your browser. Preserves attribute order, CDATA and self-closing tags exactly as written. Free and client-side.
🔒 100% Client-Side Processing
Your data is processed entirely in your browser and never transmitted to any server.
Input
<note to="Tove" from="Jani"><heading>Reminder</heading><body>Do not forget me</body><meta/></note> Output
<note to="Tove" from="Jani">
<heading>Reminder</heading>
<body>Do not forget me</body>
<meta/>
</note> Two things survive here that a DOM round trip would change: attribute order stays to-then-from rather than being alphabetised, and <meta/> stays self-closing instead of expanding into an open and close pair.
Well-formed. 280 bytes in, 312 out.
Common Use Cases
Reading an API or SOAP response
Paste a single-line response body and get an indented tree, so the element you are looking for is findable without a parser or an editor.
Diffing configuration files
Normalise the indentation of pom.xml, web.config or an Android manifest before comparing two versions, so the diff shows real changes rather than formatting noise.
Shrinking a payload before sending it
Strip the whitespace between elements when the document is going into a request body or a size-limited field, without touching the text inside it.
Frequently Asked Questions
- Does formatting change my XML?
- Only the whitespace between nodes. This page tokenises the source rather than round-tripping it through the browser DOM, because DOMParser and XMLSerializer quietly rewrite things: they collapse an empty <tag></tag> pair into <tag/>, re-encode entity references, and drop the XML declaration entirely. Attribute order, CDATA sections, comments, the DOCTYPE and its internal subset, and self-closing form all come back exactly as you wrote them.
- Why is my XML rejected as not well-formed?
- Three checks run before anything is printed, and each names the tag at fault: a closing tag with no opening tag, a mismatched pair such as <a><b></a>, and a tag left unclosed at the end of the document. XML is stricter than HTML here — there are no optional closing tags and no implied nesting repairs, so a document that a browser would silently fix is genuinely invalid as XML.
- What happens to mixed content like a paragraph with inline tags?
- It is left on one line untouched. In <p>Hello <b>world</b> and more.</p> the spaces around the inline tags are part of the text, so indenting the children would insert newlines into content and change what the document says. When an element holds both text and child elements, this formatter stops reformatting inside it — a deliberate refusal rather than a limitation.
- How do I format XML in VS Code or Notepad++?
- VS Code formats the active file with Shift+Alt+F on Windows and Linux, or Shift+Option+F on macOS, though XML needs an extension such as XML Tools or Red Hat XML installed first. Notepad++ needs the XML Tools plugin from the Plugins Admin, which then offers Pretty print under its menu. Use this page when the XML is in a terminal, a log, or an API response and you do not want to save a file just to read it.
- How much smaller does minifying actually make XML?
- Usually 10-30% on indented documents, since all that is removed is the whitespace between elements — never whitespace inside a text node, which is content. The saving is smaller than minifying JSON because XML repeats every tag name in its closing tag, and that redundancy is structural. If the payload is going over the wire, gzip or brotli will beat minification by a wide margin and the two are worth combining rather than choosing between.
- Is my data private when I use this tool?
- Yes. This tool runs entirely in your browser using client-side JavaScript — nothing you type is transmitted to, logged by, or stored on any server. You can safely process confidential text, tokens, or code.