Input
Developer utility
XML Formatter
Validate, format, minify and inspect XML with mixed-content-safe serialization, parser feedback, tree view, element paths and structure statistics directly in your browser.
Paste XML to validate, format, minify and inspect its structure.
Size0 B
Elements0
Attributes0
Depth0
Output
Formatted or minified XML
Tree view
XML structure
Paths
Element paths and attributes
| # | Path | Element | Attributes | Text preview |
|---|
Examples
Common XML samples
XML quick reference
| Concept | Example | Notes |
|---|---|---|
| Root element | <root>...</root> | An XML document needs exactly one root element. |
| Attribute | <item id="1"> | Attribute values must be quoted. |
| Text node | <title>Hello</title> | Text appears between start and end tags. |
| Comment | <!-- note --> | Comments can be preserved or removed. |
| CDATA | <![CDATA[raw text]]> | CDATA preserves text without normal entity escaping. |
| Declaration | <?xml version="1.0"?> | The optional XML declaration commonly appears at the top of a file. |
XML formatting notes
- XML is stricter than HTML: tags must be closed, nested correctly and case must match.
- Attribute values require quotes, and a document must contain exactly one root element.
- Mixed content stays compact so formatting does not inject whitespace around inline child elements.
- Validation uses the browser DOMParser and therefore follows the current browser XML parser behavior.
- Browser DOMParser does not resolve remote external entities; this tool performs no server upload or network request.
XML formatter FAQ
Does this XML formatter upload my XML?
No. Parsing, formatting, minifying, tree rendering and path inspection happen locally in your browser.
Can this tool repair broken XML?
No. It reports the parser error so you can correct the source without an automatic repair changing its meaning.
Does formatting preserve mixed content and CDATA?
Yes. Elements containing both text and child elements stay compact, while CDATA, processing instructions, declarations and document types are preserved.
Can I use it for SVG, RSS and sitemap files?
Yes. SVG, RSS, Atom, sitemaps and many configuration formats are XML and can be inspected here.