UTILS.
100% in-browser
</>

XML Formatter

Pretty-print XML with indentation or minify it down to a single line.

output

About this tool

XML Formatter is a free, in-browser tool that pretty-prints or minifies XML markup. Paste your markup and choose Format to spread each tag onto its own line, indented by nesting depth, or Minify to strip the whitespace between tags and collapse everything onto a single line.

Formatting is string-based rather than a full parse: it collapses whitespace that sits between tags, puts each tag on its own line, and indents two spaces per level. Closing tags step the indentation back out, while the XML declaration, processing instructions, comments, and self-closing tags stay on one line without adding a level. Text inside an element and every attribute are left exactly as written.

Because it doesn't parse the document, there is no schema check and no guarantee your markup is well-formed. Everything runs entirely in your browser, so nothing is uploaded, there are no accounts and no tracking, and it keeps working offline once the page has loaded. A copy button grabs the result in one click.

Frequently asked questions

Does it validate the XML?
No. It does string-based formatting and does not parse the document or check that your markup is well-formed, so malformed input is reshaped rather than rejected.
What does minify do?
It removes the whitespace between tags and trims the ends, collapsing the markup onto a single line. Text inside an element is left intact.
How much does it indent, and can I change the width?
Formatting uses a fixed two spaces per nesting level and the width is not configurable. Each tag goes on its own line, and closing tags reduce the indentation.
Does formatting change my content or attributes?
It only collapses whitespace that sits purely between tags. Element text and attributes are preserved as written, and self-closing tags, comments, and the XML declaration are kept on one line without adding an indent level.

More tools