How to use the XML Formatter
- 1
Paste XML, SVG, XHTML, an RSS feed or a config file into the Input pane, drop a file onto it, or press Sample.
- 2
The formatted result appears on the right as you type. Choose 2 spaces, 4 spaces or tabs for indentation.
- 3
If the document is not well formed, the status line names the problem and the editor underlines the exact spot. Fix it and the output updates.
- 4
Switch to Minify to strip comments and whitespace between elements for a compact single-line document.
- 5
Press Copy to take the result, Download to save it as an .xml file, or the arrow button to feed the output back into the input.
Features
- Pretty prints XML with consistent indentation, one element per line
- Validates well-formedness and pinpoints mismatched, unclosed or duplicate tags and unquoted attributes with line and column
- Keeps mixed content such as XHTML paragraphs on one line so whitespace meaning survives
- Preserves the XML declaration, DOCTYPE, comments, CDATA sections, namespaces and processing instructions
- Minifies by removing comments and inter-element whitespace while keeping text intact
- 2 or 4 space or tab indentation, remembered on your device
- Handles SVG, XHTML, RSS, Atom, XSD, XSLT, plist, pom.xml and csproj files
- Runs entirely in your browser; nothing is uploaded
Why format XML
XML written by machines arrives on one line or with indentation from whatever generated it. Reading a SOAP response, a Maven pom.xml, an Android layout or an SVG exported from a design tool is slow until the structure is visible. Formatting puts one element per line with indentation that shows the nesting, so the shape of the document is obvious and a diff shows only real changes.
The formatter is also a quick well-formedness check. XML parsers stop at the first error with a message that is often unhelpful, such as a complaint about the end of the file when the real problem is an unclosed tag a hundred lines earlier. This tool names the unclosed element and underlines where it was opened.
What is preserved
The declaration, DOCTYPE (including an internal subset), comments, CDATA sections and processing instructions are kept and placed on their own lines. Attribute values are never touched, and attributes are written one space apart in their original order. Text content of simple elements is kept with its internal spacing collapsed, and elements with mixed content keep their inline children on one line.
Related tasks
For JSON the JSON Formatter adds tree and table views. To format HTML, CSS, JavaScript and SQL alongside XML, use the full Code Formatter, which detects the language automatically.
Frequently asked questions
What does well formed mean, and is this a validator?
Why are some elements kept on one line?
Will formatting change my data?
Can I format SVG or XHTML?
How does Minify differ from the formatter's output?
Is my XML uploaded anywhere?
Last updated .