XML Formatter

Paste XML to pretty-print it with consistent indentation, or switch to minify to strip whitespace down to one line. The document is parsed with your browser's XML engine, so malformed markup is flagged before formatting.

Paste XML, then press Format XML.

What formatting does

XML is whitespace-tolerant: a document with no line breaks behaves identically to a nicely indented one, but the indented version is far easier for a human to read and diff. A formatter re-emits the same tree with one element per line and a fixed indent per nesting level.

parse → tree → re-serialize with indentation

This tool parses your XML with the browser's DOMParser, then walks the node tree and prints each element on its own line, indenting children by your chosen width. Because it works on the parsed tree rather than text, it can also catch structural errors.

Worked example

The one-line input <root><item id="1">Hello</item></root> becomes:

<root>
  <item id="1">Hello</item>
</root>

Validation and minify

If the markup is not well-formed — an unclosed tag, a stray &, mismatched names — the parser reports a parse error and the tool shows it instead of mangling the text. Minify mode does the reverse: it removes the whitespace between tags to produce the smallest valid one-line document, useful for transport or storage. Everything runs locally, so private XML never leaves your browser.

Tip: working with JSON or YAML instead? Try the JSON formatter or the YAML to JSON converter.

Frequently asked questions

Does it validate my XML?

It checks that the document is well-formed — tags are balanced and properly nested. If not, the browser's parser reports the error and formatting stops, so you never get scrambled output.

What is the difference between beautify and minify?

Beautify adds line breaks and indentation for readability; minify strips that whitespace to make the smallest valid single-line document. Both describe the same XML tree.

Does formatting change my data?

No. The element names, attributes, text and structure are preserved exactly — only insignificant whitespace between elements changes. The meaning of the document is identical.

Is my XML uploaded?

No. Parsing and serialization use your browser's DOMParser and XMLSerializer locally. Nothing you paste is sent to a server.

MB
Mustafa Bilgic · Editor, Calcool
Parses with the browser DOMParser and re-serializes with indentation. Everything runs in your browser - nothing you enter is uploaded, logged or stored.

Related calculators