XML Formatter & Viewer — beautify & validate online

Indent messy XML into something readable, validate its structure, or minify it back down. Free, instant, and the document stays inside your browser.

Input
Output

About the XML formatter tool

XML has been quietly running critical systems for twenty-five years, and it is not going anywhere. SOAP web services, RSS and Atom feeds, SVG graphics, Android layouts, Maven and Spring configuration, Office document internals, sitemaps, invoicing standards and most banking and healthcare interchange formats are all XML. Anyone integrating with an established enterprise system will meet it, usually as one enormous unbroken line.

Indenting reveals the nesting, and with XML the nesting is the whole point. A response fifteen elements deep is impossible to reason about as a single line and obvious as an indented tree — you can see which element closes where, which attributes belong to which node, and where the structure diverges from what the specification described. That is the difference between reading a document and guessing at it.

Validation here means well-formedness, which is the check that catches most real problems: every opening tag closed, tags nested rather than overlapping, attribute values quoted, one root element, and the five reserved characters escaped properly. That last one causes more failures than anything else, because an ampersand or an angle bracket appearing raw in text content will break a parser even though it looks entirely innocent.

Well-formed is not the same as valid, and the distinction matters when a system rejects your document. Well-formed means the syntax is correct. Valid means it also conforms to a schema — the right elements in the right order with the right types — which requires the XSD or DTD to check against. A document can be perfectly well-formed and still be refused for having a field in the wrong place.

How it works

1

Paste your XML

Drop in a SOAP response, a config file, an RSS feed or an SVG. It never leaves your browser tab.

2

Indent or minify

Expand it into a readable tree, or collapse it back to a single line for embedding in a request or a field.

3

Check the structure

Malformed markup is reported so you can find the unclosed tag or unescaped character causing the failure.

Frequently asked questions

What is the difference between well-formed and valid XML?
Well-formed means the syntax is correct — tags closed and properly nested, attributes quoted, a single root element. Valid means it additionally conforms to a schema defining which elements may appear, in what order and with what types. This tool checks well-formedness. Schema validation needs the XSD or DTD, which is specific to the system you are integrating with.
Why does an ampersand break my XML?
Because five characters are reserved and must be escaped in text content: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &apos;. A raw ampersand starts what the parser reads as an entity reference, and when no valid entity follows it, the document fails. URLs with query parameters are the most frequent source of this.
Does formatting change what the XML means?
Usually not, but XML is stricter about this than JSON. Whitespace between elements is generally insignificant and safe to add, however whitespace inside text content is part of the data, and elements declared with xml:space="preserve" must keep it exactly. For ordinary configuration and message documents, indenting is safe. For documents where text content is whitespace-sensitive, be careful.
Can it handle namespaces?
Yes. Prefixed elements such as soap:Envelope and xsi:type are formatted correctly, and namespace declarations are preserved as written. Namespaces are a source of integration failures in their own right, but the failure is normally a mismatched URI rather than malformed syntax, which is a schema and configuration matter rather than a formatting one.
Will it work with SVG and HTML?
SVG is XML, so it formats correctly and this is a good way to read a machine-generated one. HTML is not XML — it permits unclosed tags such as br and img, and attributes without quotes — so real-world HTML will usually be reported as malformed. That is correct behaviour rather than a bug; XHTML, being genuine XML, works fine.
Is my document uploaded anywhere?
No. Parsing and formatting run inside your browser tab, so nothing is transmitted, stored or logged. XML in the wild tends to be SOAP payloads carrying credentials, invoices with customer details or configuration containing connection strings, none of which should be pasted into a website that sends data to a server.
How large a document can it format?
Several megabytes are handled comfortably. Beyond that, the constraint is the browser displaying a very large formatted document rather than the parsing. Enterprise XML exports can be enormous — if you are inspecting one, extracting the message or record you actually need first will be considerably faster to work with.

Related tools