XML Formatter
Pretty-print or minify XML, with the line and column of any parse error.
Results are provided as is, for general information. Check anything important before relying on it. See the Terms of Use.
About this tool
Machine-generated XML — SOAP envelopes, RSS feeds, build files, config exported from a tool — often arrives on a single line or indented inconsistently. This formatter reindents it with 2- or 4-space steps, or collapses it to one line when you want it minified. It does not round-trip through a data model, so nothing is lost: the XML declaration, comments, CDATA sections and processing instructions come back exactly as they went in. An element that directly contains text is kept on one line, so mixed content like a paragraph with inline tags is not broken across lines. Malformed markup is reported with the line and column where parsing stopped. Everything happens in your browser.
When to use it
Questions
Does formatting change what my XML means?
For element-only content, added or removed whitespace between tags is insignificant and the meaning is unchanged. For an element that contains text, whitespace can be significant — so the tool leaves those elements on a single line and does not touch the text inside them. If your schema uses xml:space="preserve", review the result before relying on it.
Are comments and CDATA kept?
Yes, verbatim. The formatter tokenizes the markup rather than parsing it into a tree, so comments, CDATA sections, the <?xml?> declaration and processing instructions all survive unchanged. Only the whitespace between block-level elements is rewritten.
What counts as an error?
Anything that is not well-formed: a tag that is never closed, mismatched open and close tags, an attribute without quotes, stray < or & in text. The message gives the line and column of the first problem. Namespace prefixes are allowed; the tool does not require a schema.
Can it format an HTML document?
Only if the HTML is also well-formed XML (XHTML). Real-world HTML with unclosed <br> or <img> tags, or bare attributes, will be reported as an error. Use the Code Beautifier for HTML.