Skip to content
Expensico

XML Formatter

Pretty-print or minify XML with validation and precise error locations. Handles namespaces, CDATA and comments, entirely in your browser.

Runs in your browser. Everything you enter stays on your device. Nothing is sent to a server.

How to use the XML Formatter

  1. Paste XML or open a file (.xml, .svg, RSS/Atom feeds).
  2. Choose Beautify or Minify and an indentation.
  3. Fix any errors shown with their line and column, then copy or download.

Validation first

Before formatting, the XML is checked for well-formedness: every tag closed and correctly nested, attribute values quoted, a single root element. Formatting broken XML would hide the problem, so you get a precise error instead.

What's preserved

Comments, CDATA sections, processing instructions (like <?xml …?>) and the DOCTYPE are kept exactly. Elements that contain only text stay on one line. Minify removes whitespace between tags and comments; text inside elements is kept.

Related tools

Explore a document as a tree in the XML viewer, or convert it with XML to JSON.

Frequently asked questions

Does it validate against an XSD schema?

No. It checks that the XML is well-formed, not that it matches a particular schema.

Is whitespace in text changed?

Leading and trailing whitespace around text between tags is trimmed when formatting. If your format treats that whitespace as meaningful (rare outside xml:space="preserve"), keep the original.

Is what I enter stored or sent anywhere?

No. Calculations and processing happen in your browser. Nothing you type is sent to our servers. Some tools remember your last input in this browser's local storage for convenience; you can clear it at any time.