Format, minify, validate
Format pretty-prints your XML with one element per line and consistent indentation, so nesting you could not see in a single-line feed becomes obvious. Minify does the opposite, stripping the whitespace between elements to shrink the document for storage or transfer. Both parse the input first with your browser's own XML parser, so either button doubles as a validator: if the document is broken you get the parser's error message, usually with a line number, instead of mangled output.
Everything happens in your browser. Feeds, sitemaps, invoices, SOAP payloads and config files are never uploaded anywhere.
The errors that catch everyone
Unquoted attribute values and stray angle brackets round out the list. XML is deliberately strict: unlike HTML, which browsers repair silently, an XML parser refuses the whole document at the first error. That strictness is why the format is still trusted for sitemaps, RSS and Atom feeds, and business documents where a silently guessed repair would be worse than a hard failure.
What formatting preserves and what it normalises
Element names, attributes and their values, text content, CDATA sections, comments and processing instructions all survive formatting, and the XML declaration at the top of your document is kept if present. What changes is whitespace: indentation between elements is rebuilt from scratch, and text inside elements is trimmed. For data documents, which is almost everything XML is used for, that is exactly what you want. For documents with significant mixed content, where spaces between inline elements carry meaning, treat the formatted output as a reading copy rather than a replacement.
Attribute values are re-quoted with double quotes and special characters are re-escaped consistently, so two documents that mean the same thing come out looking the same, which makes formatted XML far easier to diff.
Case matters too, which trips up people arriving from HTML. In XML, <Item> and <item> are two different elements, and a document that opens one and closes the other will not parse. The same strictness applies to attributes: each name may appear only once per element, and every value needs its quotes. If you maintain an RSS or Atom feed, or an XML sitemap for search engines, pasting it here before publishing is a ten-second check that catches the mistakes feed readers and crawlers reject silently.
When to minify
Whitespace between elements is usually insignificant to machines but it adds up fast: an indented document can easily be a third larger than its minified twin. Minify when the document travels over the network or sits in bulk storage and no human reads it in transit. Keep the pretty form for anything a person debugs, reviews or keeps in version control, since a one-line diff on a minified file tells you nothing. A common workflow is to paste a minified API response here, format it to find the element you care about, then carry on with the minified original untouched.
Frequently asked questions
Is my XML uploaded anywhere?
No. Parsing and formatting happen entirely in your browser with the DOMParser built into it. Feeds, sitemaps, invoices and config files never leave your device, which makes the tool safe to use with data you would not paste into an unknown website.
Why does my XML fail to parse?
The most common causes are a tag that is opened but never closed, tags closed in the wrong order, a bare ampersand that needs escaping as an entity, an attribute value missing its quotes, or more than one root element. The error message shown comes from your browser's parser and usually includes a line number.
Does formatting change my data?
Element names, attributes, values and structure are all preserved. Whitespace between elements is normalised, which is what pretty printing means, and text inside elements is trimmed. If your document treats spaces and newlines inside mixed content as significant, keep a copy of the original.
What is the difference between XML and HTML?
HTML is a specific vocabulary with forgiving parsing rules, while XML is a generic strict format for any vocabulary. XML requires every tag to be closed, attributes to be quoted and a single root element. Browsers repair broken HTML silently, but broken XML simply fails to parse.
When should I minify XML?
Minifying strips the whitespace between elements, which shrinks payloads sent over the network or stored in bulk. It is worth doing for machine-to-machine traffic where no human reads the document. For anything a person needs to inspect or diff, the pretty printed form is worth the extra bytes.