Pretty-print or minify XML and catch well-formedness errors.

Output

Output will appear here
Technical details
Operation
Parse with DOMParser, then serialize with 2-space indentation or minify
Validation
Well-formedness only: matching tags, one root, legal names
Not checked
DTD, XSD, or Schematron schemas
Preserved
Element names, attributes, text, comments and CDATA
Privacy
Runs in your browser; nothing leaves this tab
Private ● What you enter stays on your device What you enter stays on your device.No account required.Nothing stored unless you choose to save it.
▸ More about

Uses of XML formatting

  • Tidying a one-line SOAP or RSS payload from a log
  • Checking a config file is well-formed before deploy
  • Minifying XML for a size-sensitive embed

XML formatting pitfalls

  • Expecting XSD validation from a well-formedness check
  • Assuming tag case does not matter the way it often does in HTML

XML formatting questions(8)

What does the XML Formatter change?

Only layout when the document is well-formed. Pretty print uses two-space indentation and puts nested elements on their own lines. Minify removes insignificant whitespace between elements. Element names, attributes, text, comments and CDATA stay the same.

What does validate mean here?

Well-formedness: one root element, matching start and end tags, and legal names. It does not check an XSD, DTD or Schematron schema. Therefore a document can be well-formed and still fail a schema your API expects.

Why is XML case sensitive?

XML treats Book and book as different element names. HTML is more forgiving in browsers. If a close tag does not match the open tag exactly, including case, the document is not well-formed and the formatter reports an error instead of guessing.

How do XML namespaces show up?

A namespace is a URI bound to a prefix (xmlns:book="...") or to the default xmlns. Prefixed names stay as written. This page does not resolve external DTDs or schemas, so namespace URIs are kept as attributes rather than fetched.

Is my XML sent to a server?

No. Parsing and formatting run in your browser with the built-in DOMParser. Nothing leaves this tab and nothing is stored remotely.

Where is the error line taken from?

From the browser parser message when it includes a line (and sometimes a column). Different browsers word that message differently. If no line is present, the status still shows the malformed XML message.

Can I minify XML as well as pretty-print it?

Yes. Choose Minify in the mode control. Insignificant whitespace between elements is removed so the payload is smaller while the infoset stays the same.

Will formatting change what my XML means?

No for element structure and attribute values. Whitespace-only text nodes between elements are normalised when pretty-printing, which matches how most documents treat insignificant whitespace.

XML Formatter: Pretty Print Without UploadAll Developer Utilities