Skip to content

Minify XML

Remove insignificant whitespace and optional comments from XML, with a before-and-after size readout. Parsed first, so the output is always valid.

  • Runs in your browser
  • Files are never uploaded
  • Free, no account
Minify XML
Remove insignificant whitespace and, optionally, comments. The document is parsed first, so a result means the input was well-formed.
Your XML never leaves this tab — check it yourself—

Starting the network probe…

The counter above wraps fetch, XMLHttpRequest and navigator.sendBeacon in this tab and counts every call. It does not block anything — it just reports.

Two ways to verify independently

  1. Turn off Wi-Fi or enable airplane mode, then use the tool. It keeps working, because the page is already fully loaded.
  2. Open your browser devtools, switch to the Network tab, clear it, and run the tool. No new row appears.

Why this matters

In 2025 researchers found that popular online formatters had retained tens of thousands of user-submitted snippets — JSONFormatter.org and CodeBeautify together exposed roughly 80,000 saved documents, many containing live cloud credentials, private keys and internal database connection strings, because “format this” quietly meant “upload this”. A separate incident exposed roughly 3.5 million user PDFs on a document-conversion service. The only structural fix is not sending the data in the first place: this site is served under a Content-Security-Policy whose connect-src contains no third-party origin, so a request off this device cannot be made even by accident.

Which whitespace is safe to remove

XML has no concept of insignificant whitespace at the specification level — every character in a text node is data. In practice, a text node that consists only of spaces and newlines between two elements is indentation that a pretty printer added, and removing it changes nothing that any consumer cares about. That is the only whitespace this tool removes by default.

Text nodes with actual content are preserved. You can optionally collapse runs of whitespace inside them to a single space, which is what an HTML renderer would do anyway — but it is off-by-default territory if your document uses xml:space="preserve", contains preformatted text, or is a document format where a double space is meaningful.

Why XML shrinks more than JSON

XML repeats every element name twice — once to open and once to close — and adds angle brackets to both. A field called customerReference costs 4 characters in JSON ("…": plus the value) and 36 in XML before the value is even written. Add one level of indentation per depth and an indented XML document is frequently 40–50% whitespace. A typical minification saves 20–50%; the exact figure for your document appears above the output.

Self-closing tags

<a></a> and <a/> are exactly equivalent to an XML parser — the specification says so explicitly — and the short form saves bytes, so it is applied by default. Turn it off if a downstream consumer is not a real parser. Hand-rolled regex readers, some legacy SOAP stacks and a few embedded XML libraries mishandle self-closing tags, and that is a real-world constraint rather than a hypothetical one.

Compression beats minification, but not always

Serving XML with gzip or Brotli reduces transfer size far more than minifying does, and it costs one line of server configuration. Minify when the constraint is on the uncompressed bytes:

  • A SOAP payload against a gateway with a message-size cap.
  • An XML column in a database, or an XML field inside another document.
  • An embedded or industrial device with a fixed receive buffer.
  • A signed document where you want a stable, compact canonical form — though note that real XML canonicalisation (C14N) is a different, stricter transformation than minification.

Comments

Removing them is optional and worth thinking about. Comments in configuration files (web.config, Maven POMs, Android manifests) often explain why a setting exists, and that context is worth more than the bytes. Comments in a generated payload almost never are.

Questions

Which whitespace is safe to remove?

Whitespace-only text nodes between elements — the indentation a pretty printer added. Whitespace inside a text node that also contains characters is preserved, and can optionally be collapsed to a single space. If your document relies on `xml:space="preserve"`, minify with care.

How much does XML shrink?

Usually 20–50% for a document that was indented, because XML has more markup per byte of data than JSON does. The exact figure for your file is shown above the output.

Should I minify a sitemap or an RSS feed?

You can, but serve it with gzip or Brotli first — compression does far more for transfer size than minification, and consumers do not care about the layout either way. Minify when there is a hard byte limit, such as an SMS/MMS gateway payload or an embedded device.

Are empty elements collapsed?

Optionally. `<a></a>` and `<a/>` are exactly equivalent to a parser, and the short form saves bytes, so it is on by default. Turn it off if a downstream consumer of yours is not a real XML parser and mishandles self-closing tags.