Pretty-print or minify XML with configurable indentation.
The XML Formatter pretty-prints XML with consistent indentation or minifies it onto a single line. It checks that the document is well-formed while it works and reports the line and column of the first problem. Use it to read minified API responses, tidy config files, or shrink XML before embedding it.
XML is a text format built from nested elements, attributes and text. Whitespace between elements is normally insignificant, so the same document can be written on one line or spread over many indented lines without changing its meaning. Formatting (pretty-printing) adds line breaks and indentation so the nesting is visible; minifying removes that whitespace to make the document smaller. To do either safely the tool must first parse the document, which also proves it is well-formed: every start tag has a matching end tag, tags nest properly, attribute values are quoted and there is a single root element. Whitespace inside text content is trimmed when formatting, so formatting is for reading and tidying, not for documents where leading or trailing spaces in text matter.
It changes only whitespace between elements and trims leading and trailing whitespace inside text nodes. Element names, attributes, comments, CDATA sections and text values are kept. If your document depends on exact whitespace inside text, keep the original.
Format puts each element on its own line with the chosen indentation. Minify removes the whitespace between elements so the document is as compact as possible.
DOCTYPE and entity declarations can be used to define entities that expand into very large or external content. The tool rejects them rather than processing them. Remove the declaration to format the rest of the document.
Yes. Set Indent to Tab and each nesting level is indented with one tab character.
No. The document is parsed and formatted in the page, and the input is not sent to a server.
No. It checks that the XML is well-formed, which means correctly structured. It does not check the document against an XSD or DTD.