XML Formatter

Pretty-print or minify XML, validated by the browser's own parser.

Loading the interactive tool… It runs in your browser — if it doesn't appear, enable JavaScript.

Paste XML and get it indented with proper nesting, or minified to a single line. Simple leaf elements stay on one line, so `<title>Dune</title>` isn't spread across three, which keeps the output readable rather than merely correct.

Validation uses your browser's own XML parser, so "well-formed" here means exactly what it means to the software that will consume the file — not the opinion of a hand-rolled checker that may be stricter or looser.

Frequently asked questions

What's the difference between well-formed and valid XML?

Well-formed means the syntax is correct: tags are closed, properly nested, attributes are quoted, and there's a single root element. Valid means it additionally conforms to a DTD or XSD schema — correct element names, in the right order, with the required attributes. This tool checks well-formedness only; schema validation needs the schema.

Why did my XML fail to parse?

The most common causes are an unescaped ampersand (write `&amp;`), a stray `<` in text content, mismatched or unclosed tags, and multiple root elements. The error message points at the position where the parser gave up, which is usually just after the real problem rather than at it.

Does formatting change the document's meaning?

It can, in principle. Whitespace inside a text node is significant in XML unless a schema says otherwise, so reformatting a document with mixed content is not always safe. This formatter preserves text content verbatim and only adds indentation between elements, which is safe for the structured, data-style XML most people are working with.