Developer Tools

XML Formatter & Minifier — Free, Instant, No Upload

🔒 Runs in your browser

Paste your XML to instantly format it with clean indentation, or minify it to a single compact line. Works entirely in your browser — no server, no upload, no waiting.

How to use this tool

  1. Paste your XML into the input field.
  2. Choose indentation level.
  3. Copy the formatted XML.
Indent:

About XML Formatter & Minifier

This tool tidies XML markup. In format mode it re-indents the document so each element sits on its own line at a depth that reflects how deeply it is nested, using either two or four spaces per level. In minify mode it does the opposite, collapsing the whitespace between tags and squeezing runs of spaces down so the whole document becomes one compact line, which is handy for embedding XML in a string or shrinking a payload. The indentation selector is active only in format mode, since minified output has no indentation to configure.

The formatter works by normalizing the spacing between tags, then splitting the markup into individual tokens at each tag boundary and walking through them while tracking nesting depth. Opening tags increase the depth for the lines that follow, closing tags decrease it, and self-closing tags as well as declarations beginning with an exclamation mark are treated as standalone so they do not shift the indentation. An element written inline as a tag, its text, and its closing tag on one token is kept together rather than being split apart. This produces clean, readable output for typical configuration files, SVG snippets, RSS feeds, and SOAP or API responses.

The approach is string based rather than a full parsing model, so it is fast and runs instantly as you type. It is not a validator: it does not check that tags are correctly nested, that a schema or DTD is satisfied, or that namespaces resolve, and CDATA sections, comments, and processing instructions are handled as ordinary text rather than given special treatment. As a lightweight guard it does reject input that contains no angle bracket at all, flagging it as not looking like XML. Everything happens in your browser, so the markup you paste is never sent anywhere.

Use it to make a dense one-line export readable before you inspect it, to standardize indentation before committing a config file, or to compress a formatted document back down for transport. For documents that must be checked against a schema, pair it with a dedicated validator after formatting.

Frequently Asked Questions

What is the difference between format and minify?
Format re-indents the XML so each tag is on its own line at a depth matching its nesting, making the structure easy to read. Minify removes the whitespace between tags and collapses extra spaces so the document becomes a single compact line, which is useful for embedding or reducing size.
Can I choose the indentation width?
Yes, you can pick two or four spaces per nesting level. The selector applies only in format mode; in minify mode it is disabled because the output deliberately has no indentation.
Does the tool validate my XML?
No. It reformats and minifies markup but does not perform validation. It will not tell you whether tags are properly nested, whether a schema or DTD is satisfied, or whether namespaces resolve. As a basic sanity check it does flag input that contains no angle brackets as not appearing to be XML.
How are CDATA sections, comments, and declarations handled?
Declarations and tags that begin with an exclamation mark, such as DOCTYPE, are treated as standalone lines that do not change indentation. CDATA sections and comments are processed as ordinary text rather than being given special parsing, so unusual content inside them may not be indented as you might expect.
Will inline text inside an element stay on one line?
Yes. When a tag, its text content, and its closing tag arrive together as a single token, the formatter keeps them on the same line rather than breaking them onto separate lines, which keeps short text elements compact and readable.
Why does it say my input does not appear to be XML?
The tool requires at least one angle bracket to consider the input XML. If you pasted plain text, JSON, or a fragment with the brackets stripped out, it shows that message instead of attempting to format non-markup content.
Is it a full XML parser?
No. The formatting is done with fast string transformations and depth tracking rather than a complete parsing engine. This makes it instant and lightweight, but it means edge cases that a strict parser would handle, such as malformed nesting, are not detected or corrected.
Does my XML leave the browser?
No. All formatting and minifying happen locally in your browser, so nothing you paste is uploaded to a server.
Embed this tool on your site

Free. One line of HTML — the tool runs in your visitor's browser, no data sent to anyone.

<iframe src="https://brevio.pro/embed/xml-formatter" width="100%" height="600" loading="lazy" style="border:1px solid #e5e5e5;border-radius:8px" title="XML Formatter & Minifier — brevio"></iframe>
<p style="font:12px/1.4 sans-serif"><a href="https://brevio.pro/tools/xml-formatter">XML Formatter & Minifier</a> by <a href="https://brevio.pro">brevio</a></p>
More free toolsSee all 492 →
XML Formatter & Minifier — Free, Instant, No Upload | brevio