XML Formatter
Format & validate XML
What Is This Tool?
The XML Formatter re-indents an XML document with 2-space indentation per nesting level, making deeply nested elements easy to read. It can also minify XML down to a single line and validate that a document is well-formed. Everything runs locally using your browser's built-in XML parser.
How to Use
Paste your XML into the input box.
Click Format to indent it, or Minify to compress it.
Use Validate to check it is well-formed XML.
Copy the result or download it as a .xml file.
Features
- 2-space indented formatting
- One-click minification
- Well-formedness validation with error detail
- Preserves attributes and self-closing tags
- Copy to clipboard or download as a file
- 100% client-side — nothing leaves your browser
Examples
Before (minified):
<catalog><item id="1"><name>Widget</name></item></catalog>
After (formatted):
<catalog>
<item id="1">
<name>Widget</name>
</item>
</catalog>
Common Use Cases
- Reading a minified SOAP or REST XML response
- Checking a config or feed file is well-formed
- Shrinking XML before storing or transmitting it
- Preparing readable XML samples for documentation
Frequently Asked Questions
Is my XML uploaded anywhere?
No. Formatting, minifying and validation all happen locally in your browser using the built-in DOMParser and XMLSerializer.
Does this validate against a schema (XSD/DTD)?
No, it only checks that the XML is well-formed (correctly nested tags, matching quotes, valid characters), not that it conforms to a specific schema.
Is minification exact for all documents?
Minify is a best-effort operation: it collapses whitespace between tags. If your document relies on significant whitespace inside text content, review the minified output before using it.
What happens if my XML isn't well-formed?
Validate and Format will show the parser's error message so you can see what's wrong, such as a mismatched or unclosed tag.
Can I download the formatted result?
Yes, click Download to save the current output as a data.xml file.