XML Formatter
Indent XML for reading or minify it for transport, with unbalanced tags reported by line number.
Processed locally in your browser — nothing is uploaded.
XML Formatter
0 characters
Formatted XML
Output appears here…About XML Formatter
Pretty-print XML with consistent indentation, or collapse it to a single line. Declarations, comments, CDATA sections, and self-closing tags all survive the round trip untouched.
Short text nodes stay on the same line as their element, so a document full of small values does not balloon to three times its height.
Common uses
- Read an RSS feed, sitemap, or SOAP response that arrived as one long line
- Find the mismatched tag in a config file that a parser rejected
- Minify an XML payload before embedding it in a test fixture
Example
Input
<catalog><book id="1"><title>Widgets</title></book></catalog>
Output
<catalog>
<book id="1">
<title>Widgets</title>
</book>
</catalog>Limitations
- Structural formatting only — no DTD or XSD schema validation, and entities are left as written
- Attribute order and whitespace inside text nodes are normalised, not preserved byte-for-byte
Frequently asked questions
Does my XML leave the browser when I format it?
No. Parsing and formatting happen locally in your browser with nothing sent to a server, so config files, API responses, and feeds containing internal data stay on your device.
Can this tool tell me why my XML won't parse?
It reports structural errors with line numbers — a closing tag with no opening tag, mismatched tag names, an unclosed comment or CDATA section. It does not validate against a DTD or XSD schema, so a well-balanced document can still violate its schema.
Why do some XML elements stay on one line after formatting?
An element whose only content is a short text value (60 characters or less) is kept inline as <tag>value</tag>. This stops documents full of small values from tripling in height while nested elements still get their own indented lines.
Are XML comments and CDATA sections kept when formatting?
Yes. Comments, CDATA sections, XML declarations, doctypes, and self-closing tags all survive both formatting and minification unchanged — only indentation and whitespace between elements are rewritten.
Is it safe to minify XML that contains significant whitespace?
Mostly, but not always. Whitespace runs inside text nodes are collapsed to a single space and trimmed, so a document that relies on exact spacing in mixed content (some document formats do) is not preserved byte-for-byte. CDATA content is left untouched.