XML Formatter
NewFormat, beautify, and minify XML documents with syntax validation.
No validation results yet.
Frequently Asked Questions
Why did my XML comments and blank indentation disappear after formatting?
This formatter removes comments and whitespace-only text nodes before rebuilding the XML. That keeps the output clean, but it also means formatting-only whitespace and comment nodes are not preserved.
Will it keep my <?xml version="1.0"?> declaration?
Yes. If your input starts with an XML declaration, the formatter preserves it and prepends it back onto the formatted or minified output.
Can I switch between 2 spaces, 4 spaces, and tabs?
Yes. The indent selector supports 2 spaces, 4 spaces, or tabs, and changing it will reformat the current valid XML output automatically.
Why does the validator show a line, column, and the bad line itself?
The tool parses with DOMParser, reads the parsererror text, and extracts line and column info when the browser provides it. It also prints the offending source line to make broken tags easier to spot.
Why do some elements stay on one line while others get expanded?
Elements that contain only text or CDATA stay inline, like <title>XML Guide</title>. Elements with nested child elements are expanded into multiple indented lines.