WebToolX

Command Palette

Search for a command to run...

Developer Tools

XML Formatter & Minifier

Format, beautify, and minify XML instantly in your browser. Pretty-print with 2/4 spaces or tabs, or collapse XML to a single line — fully private.

Paste XML above to format or minify it.

This XML formatter runs entirely in your browser — your XML is never uploaded or sent to a server.

XML Formatter & Minifier — Beautify or Compact XML Instantly

XML powers SOAP web services, RSS and Atom feeds, sitemaps, Android layouts, Maven and build configuration, SVG graphics, and countless legacy data exchanges. But XML pulled from an API, a log file, or a database column often arrives as one unbroken line — almost impossible to read. This XML Formatter parses that dense blob and re-indents it with clean line breaks so the element hierarchy is obvious at a glance. Need the opposite? Click Minify to collapse the document back to a single compact line, perfect for embedding in a request body, an environment variable, or a tightly-budgeted payload.

How to Use the XML Formatter

  • Paste your XML into the input box — a full document or just a fragment.
  • Click Format to pretty-print it with your chosen indentation: 2 spaces, 4 spaces, or a tab.
  • Click Minify to strip the whitespace between tags and produce the smallest valid representation.
  • Copy the result to your clipboard with a single click and paste it wherever you need it.
  • Press Try an example to load a sample document if you want to see the tool in action first.

Private by Design

Everything happens locally in your browser using a small, dependency-free formatter — there is no server round-trip, no upload, and no logging. That client-side processing means you can safely format SOAP envelopes, configuration files, or API responses that contain credentials or customer data without it ever leaving your machine. The formatter increases indentation for each level of nested elements, keeps self-closing tags such as <br/> flat, and leaves text content untouched, so your data round-trips reliably between formatted and minified forms.

Frequently Asked Questions

What is the difference between formatting and minifying XML?

Formatting (also called beautifying or pretty-printing) adds indentation and line breaks so the nesting of your XML elements is easy to follow. Minifying does the opposite — it removes the whitespace between tags so the document occupies as little space as possible, which is ideal for transmitting over a network or storing in a configuration value. Both operations keep the same data and element structure; only the layout changes.

Is my XML uploaded to a server?

No. This formatter runs 100% inside your browser using a lightweight, hand-written parser — there is no upload step and nothing is sent anywhere. Your XML never leaves your device, which makes it safe to use with SOAP payloads, RSS feeds, configuration files, API responses, or any other XML that may contain private or proprietary data.

Does it preserve attributes, comments, and the XML declaration?

Yes. Element attributes are kept on their opening tags exactly as written, and the XML declaration (the <?xml …?> line) is placed at the top without being indented. Comments and CDATA sections are kept on their own lines. The tool re-indents the document for readability without rewriting or reordering your content.

Why does minify keep some whitespace inside my tags?

Minifying only collapses the whitespace that sits between tags, because whitespace there is insignificant. Whitespace inside a text node — for example the spaces in <name>John Smith</name> — is part of your data, so it is deliberately preserved. If text-node whitespace were stripped, the meaning of the document could change.

Related tools