About the XML Formatter
XML that comes out of a SOAP response, a Maven build or an Android manifest is often a single line or has inconsistent indentation. This formatter tokenises the document and re-indents every element one level per nesting depth. Short elements that contain only text stay on one line, so <title>Soil and Stone</title> remains readable rather than being split across three lines.
Before formatting, the document is checked with the browser's XML parser, so an unclosed tag, a stray ampersand or mismatched nesting stops the process with the line and column of the problem. Comments, CDATA blocks, the XML declaration and DOCTYPE are preserved verbatim; only whitespace between tags is changed. Attribute order is untouched and whitespace inside attribute values is never altered.
The tool does not validate against a schema or DTD; it checks well-formedness, which is what most "my XML will not load" problems come down to. For structural questions use the XML Validator, and for a collapsible view of a large file try the XML Viewer.
How to use
- Paste XML on the left, or upload a
.xml,.svg,.pomor.plistfile. - Choose an indent size. The output updates as you type.
- Copy or download the formatted document. Swap sends it to the XML Minifier.
Common questions
- Does the formatter change the content of text nodes?
- Runs of whitespace inside mixed content are collapsed to a single space, which is how XML parsers treat insignificant whitespace. Text inside CDATA sections is left exactly as it was.
- Why does it say my XML is not well-formed?
- Common causes are an unescaped ampersand (write
&), attribute values without quotes, an element closed in the wrong order, or two root elements. The message names the line and column. - Can it format SVG or XHTML?
- Yes. Both are XML dialects and format the same way. HTML that is not XHTML should go through the HTML Formatter instead, because HTML allows unclosed tags.
- Are namespaces supported?
- Yes. Namespace prefixes and xmlns declarations are ordinary attributes to the formatter and pass through unchanged.