About the XML Formatter
This XML formatter re-indents markup so nesting becomes visible at a glance, which matters when you are reading a SOAP envelope, an RSS feed, a sitemap or a hand-edited configuration file. Each element sits one level deeper than its parent, and short elements whose content is a single text node are collapsed onto one line so a list of simple fields stays compact. You can indent with two or four spaces, or flip to minify and strip the whitespace between tags. Opening and closing tag counts are reported as a quick sanity check. Formatting runs entirely in your browser, so internal service payloads are never transmitted.
How to use the XML Formatter
- 1
Paste your XML, RSS, SOAP or SVG markup into the XML box.
- 2
Choose an Indent size of 2 or 4 spaces to match your project's conventions.
- 3
Tick 'Minify instead of format' if you want whitespace between tags removed rather than added.
- 4
Compare the opening and closing tag counts in the Summary — a mismatch points to an unclosed element.
- 5
Copy the result or download it as document.xml.
What people use it for
Reading a SOAP response
Enterprise services return deeply nested envelopes on one line. Indenting them makes the Body and Fault elements findable without opening a full XML editor.
Editing an SVG by hand
SVG is XML, so an icon exported from a design tool becomes readable markup you can tidy, recolour or strip editor metadata from.
Checking an RSS feed or sitemap
Feed readers and search engines both reject malformed XML outright. Formatting exposes a stray unclosed item element long before a validator run does.
Well-formedness, validity and what this tool checks
XML draws a sharp line between two ideas. A document is well-formed if it obeys the syntax rules of the XML 1.0 specification: exactly one root element, every start tag matched by an end tag or written as self-closing, correct nesting, attribute values always quoted, and the five predefined entities used for the reserved characters ampersand, less-than, greater-than, apostrophe and quotation mark. A document is valid if, on top of being well-formed, its structure conforms to a DTD, an XML Schema or a RELAX NG grammar. Validity is document-specific and needs the schema in hand. This tool is a formatter, so it reports the number of opening and closing tags and leaves the judgement to you: equal counts are a good sign, unequal ones almost always mean an element was never closed. For genuine schema validation you need a validating parser such as xmllint with the relevant XSD supplied.
Where re-indentation is safe and where it is not
Reformatting XML is not always a no-op, because whitespace inside an element is part of its character data. A parser reading a name element padded with spaces around the text sees those spaces, and only a schema or the consuming application decides whether to trim them. This formatter adjusts whitespace between tags rather than inside text nodes, and leaves attribute values and text content byte-for-byte unchanged. The construct to watch is mixed content — an element containing both text and child elements, as in a paragraph with a bold word inside it — where inserting line breaks can introduce spaces that matter in the rendered output. XML also provides the xml:space attribute with the value preserve, which explicitly asks processors not to touch whitespace within that element. If your document uses it, review those sections after formatting rather than assuming the change is purely cosmetic. CDATA sections are likewise verbatim by definition.
Tips
- Attribute-heavy elements stay on one line, so very long lines usually mean the attributes, not the nesting, need attention.
- Minified XML is a poor format for source control — keep the indented version and minify only for transport.
- If your file begins with a byte order mark the first tag can look shifted; strip it before formatting.