Paste minified or messy XML and get clean, indented markup with well-formedness checking — or collapse it down to a single-line minified version.
Minified or inconsistently indented XML — config files, SOAP payloads, RSS feeds, SVGs, Android layouts — is hard to scan by eye. This tool parses the markup, checks that it's well-formed, and re-indents it with consistent spacing and one element per line, or collapses it down to a compact single-line version. Everything runs locally in your browser using the native DOM parser, so nothing you paste or upload leaves your device.
| Feature | Behavior |
|---|---|
| Beautify | Re-indents nested elements with a configurable indent size and tabs vs spaces |
| Minify | Strips comments, whitespace and line breaks down to a compact single-line output |
| Well-formedness check | Parses the XML and reports the line where a mismatched or malformed tag was found |
| Declaration & comments | Preserves the <?xml ?> declaration, comments, and CDATA sections |
| File upload | Upload an .xml, .xsd, .xsl or .svg file instead of pasting, then download the result |
The XML Formatter & Validator is a free online developer tool for cleaning, organizing, validating, and minifying Extensible Markup Language. Paste compressed or inconsistently formatted XML into the input editor, or upload an XML file, and transform it into readable, properly indented markup.
The tool can also validate whether your document is well-formed. It helps identify structural problems such as missing closing tags, incorrectly nested elements, unquoted attribute values, and malformed markup. If you need compact output instead, select the Minify option to remove unnecessary indentation and line breaks.
XML files can contain deeply nested elements, attributes, namespaces, comments, and text values. When all markup appears on one line, understanding the document structure becomes difficult. The beautifier inserts indentation and line breaks so that parent and child elements are clearly visible.
The validator examines whether the XML follows fundamental structural rules. Unlike HTML, XML parsing is strict: every element must be closed correctly, attribute values must be quoted, and the document must contain a valid root element.
| Feature | What It Does |
|---|---|
| Beautify | Adds consistent indentation and readable line breaks. |
| Minify | Removes unnecessary whitespace to create compact XML. |
| Well-formedness validation | Checks the basic structural correctness of the document. |
| Indent controls | Lets you select an indentation size and use spaces or tabs. |
| Self-closing tag style | Controls how empty XML elements are displayed. |
| XML declaration | Lets you preserve or remove the declaration from the output. |
Use Load sample if you want to test the available options before processing your own document. Select Clear all to remove the current input and output.
Consider this compressed product catalog:
<?xml version="1.0" encoding="UTF-8"?><catalog><product id="101"><name>Wireless Mouse</name><price currency="USD">24.99</price><inStock>true</inStock></product></catalog>
Although the document may be valid, its nested structure is difficult to inspect. Beautifying it with two-space indentation produces:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<product id="101">
<name>Wireless Mouse</name>
<price currency="USD">24.99</price>
<inStock>true</inStock>
</product>
</catalog>
The formatted version makes the root element, product attributes, and child values immediately visible. Selecting Minify converts the readable output back into a compact form when a smaller configuration value or payload is required.
A well-formed XML document follows the fundamental syntax rules required by an XML parser. It must have exactly one root element, matching opening and closing tags, properly nested child elements, quoted attribute values, and valid special-character escaping.
Well-formedness is different from schema validation. A document can be structurally valid but still fail the business rules defined by an XSD or DTD. This tool checks XML structure; it does not confirm that the document matches a particular external schema unless that feature is explicitly provided.
Beautified XML is better for debugging, editing, documentation, and version-control reviews. Indentation exposes parent-child relationships and makes missing or incorrectly nested elements easier to locate.
Minified XML removes formatting whitespace to create a smaller result. It can be useful when embedding XML into a configuration value or reducing unnecessary payload characters. Keep a readable source version whenever people must maintain the document.
Every ordinary opening element must have a matching closing element. A missing closing tag causes the document to fail well-formedness validation.
Elements must close in the reverse order in which they were opened. Overlapping tags are not valid XML.
An XML document must contain one root element wrapping all other document content. Two unrelated top-level elements make the document invalid.
XML attribute values must be enclosed in single or double quotation marks. HTML-like unquoted attributes are rejected by strict XML parsers.
Reserved characters used as text must be represented correctly. For example, use
& when an ampersand is part of a text value.
If an XML declaration specifies an encoding, the actual document must use that encoding. A mismatch can cause parsing errors or corrupted characters.