XML Formatter

Prettify, minify and validate XML with syntax highlighting and precise error locations.

Input

0 B

Press Ctrl+Enter to format.

Result

Formatted XML appears here.

About this XML formatter

Paste XML, get it back readable. Formatting, minification and validation all run in your browser — nothing is uploaded, which makes this safe to use with API responses, SOAP envelopes, config files and anything else you would rather not send to a stranger's server.

Format, minify, validate

  • Format re-indents with 2 spaces, 4 spaces or tabs. Optionally collapses <a></a> to <a/> and strips comments.
  • Minify removes the whitespace between elements and normalises tags onto one line — useful for measuring a real payload size or embedding XML in a config value.
  • Validate checks the document without changing it and reports the exact line and column of the first problem.

Well-formed is not the same as valid

This tool checks that your XML is well-formed: tags are balanced and correctly nested, attributes are quoted and unique, there is exactly one root element, and special characters are escaped. It does not check the document against a DTD or XSD schema, which is what "valid" strictly means. Well-formedness is what fails most of the time, and it is what every XML parser rejects first.

Common XML errors

Most malformed XML comes down to a few causes: a closing tag that does not match the one it closes, an element left unclosed, an unquoted attribute value, a valueless attribute like <input disabled> copied from HTML, a bare & that should be &amp;, or more than one root element. XML permits none of these, even though HTML forgives most of them.

What formatting preserves

Comments, CDATA sections, processing instructions, the DOCTYPE and namespace prefixes all survive formatting untouched. Attribute order is kept; attribute quoting is normalised to double quotes. Leading and trailing whitespace inside text nodes is trimmed, so if a document depends on exact whitespace — anything marked xml:space="preserve" — minify it rather than reformatting it.

Is my data safe?

Yes. There is no server involved — open your network tab and confirm nothing is sent. Once the page has loaded it keeps working offline.