XML Formatter

Paste your XML, choose to format (with indentation) or minify, and copy the result. Validity is checked automatically, with the exact error message if the XML isn't well-formed.

Paste your XML

Basic rules for well-formed XML

Every opened element needs a matching closing tag, or must be self-closed (<tag/>). Elements need to be properly nested, without overlapping. There must be exactly one root element wrapping the whole document. Attribute values must always be quoted, single or double.

Format vs. minify

Format: adds line breaks and indentation, making the hierarchical structure easy to read and review. Minify: removes all unnecessary whitespace between tags, reducing file size for network transmission or storage, at the cost of readability.

Limitation with mixed content

Elements that combine loose text with child tags at the same time (mixed content) may have the text broken onto separate lines from the tags when formatting — a simplification common to this kind of formatter. Simple elements with only text and no child tags stay on a single line.

Frequently asked questions

What does "well-formed" XML mean?

It means every opening tag has a matching closing tag (or is self-closed), elements are properly nested, there's exactly one root element, and attribute values are quoted. Without this, the XML can't be processed by XML readers.

Does the formatter handle mixed content (text and tags together) well?

It does, with a simplification common to this kind of formatter: when an element mixes loose text and child tags at the same time, each piece may be broken onto its own line. Simple elements with only text and no child tags stay on a single line.

What's the difference between formatting and minifying?

Formatting adds line breaks and indentation to make it easier for humans to read. Minifying removes all unnecessary whitespace between tags, reducing file size, useful for transmission or storage.

Is the pasted XML sent to a server?

No. All validation, formatting, and minifying happen locally in your browser, in JavaScript, without sending the content off your device.