XML Formatter & Minifier
Pretty-print or minify XML in your browser. Format indents every element with 2 spaces, 4 spaces or a tab; Minify removes the whitespace between tags and can strip comments. The document is checked for well-formedness first, and CDATA sections, comments and the XML declaration are kept.
How to use
- Choose Format or Minify.
- For Format, pick the Indent (2 spaces, 4 spaces or Tab); for Minify, optionally tick Strip comments.
- Paste your document into Input XML; the Output updates as you type and shows the input and output size in bytes.
- Click Copy or click Download to save formatted.xml or minified.xml. If the XML is not well-formed, you see Invalid XML — check the syntax. followed by the parser's message.
Example
Input
Mode: Format · Indent: 2 spaces
<?xml version="1.0" encoding="UTF-8"?><note id="42"><!-- draft --><to>Tove</to><from>Jani</from><body>Fish & chips at 7</body><attachments/></note>Output
<?xml version="1.0" encoding="UTF-8"?>
<note id="42">
<!-- draft -->
<to>Tove</to>
<from>Jani</from>
<body>Fish & chips at 7</body>
<attachments/>
</note>Frequently asked questions
Does it validate my XML?
It checks that the document is well-formed with the browser's built-in XML parser: tags must be closed and properly nested, there must be a single root element and attribute values must be quoted. It does not validate against a DTD or an XML Schema.
What does Minify remove?
Whitespace-only text between tags is removed, and runs of whitespace inside text are collapsed into a single space. Comments stay unless you tick Strip comments; CDATA sections and the XML declaration are always kept, and empty elements are written as <tag/>.
Can formatting change my data?
Elements, attributes and their values are kept, but the document is written out again: text is re-escaped with &, <, > and ", and empty elements become <tag/>. In Format mode, when an element mixes text with child elements, the text is trimmed and placed on its own line, which changes the whitespace in it.
Is my XML uploaded?
No. Parsing, formatting and minifying happen locally in your browser, and nothing is uploaded or logged.