XML formatter and minifier
Paste raw or minified XML and get back a clean, indented document — or collapse a formatted file back down to a single line. This is the everyday “beautify my XML” tool for developers working with SOAP envelopes, RSS/Atom feeds, Android layout files, SVG markup, sitemaps and config files that arrive as one unreadable line.
How it works
The formatter is a dependency-free pretty-printer that runs in two passes. First it
tokenizes the input on tag boundaries, classifying each chunk as an opening tag,
a closing tag, a self-closing tag (<x/>), a leaf (the <?xml ?> declaration,
<!-- comments -->, CDATA or processing instructions) or a text node. Then it
re-emits each token with indentation driven by a depth counter:
- a closing tag dedents before it prints;
- an opening tag prints, then indents its children;
- self-closing tags and leaf tokens print on their own line without changing depth;
- text sitting between an opening tag and its matching close is printed inline.
Minify mode skips the indentation entirely and joins every tag onto one line. Only whitespace between tags is touched — attribute values, text content, comments and CDATA are never altered.
Example
Paste this one-line input:
<note><to>Gera</to><body private="true">Hi</body></note>
With 2-space indentation, Format produces:
<note>
<to>Gera</to>
<body private="true">Hi</body>
</note>
Run Minify on the indented version and you get the original single line back.
| Indent option | Use when |
|---|---|
| 2 spaces | Default for most XML, SOAP and config files |
| 4 spaces | Deeply nested docs where extra width aids scanning |
| Tab | Teams that already indent with tabs |
Everything runs locally in your browser as plain JavaScript — your XML is never uploaded, so it is safe for proprietary payloads and works offline once loaded.