Format messy XML into readable, indented code, validate its structure, or minify it down to a single line.
Yes, the tool checks basic XML structure (matching tags, proper nesting) using the browser's built-in XML parser and reports errors if the document isn't well-formed.
Formatting adds indentation and line breaks for readability. Minifying removes all unnecessary whitespace to reduce file size for production use.
No, this checks only that the XML is well-formed (correct syntax), not that it conforms to a specific schema definition.
This tool formats XML documents with proper indentation for readability, validates that the XML is well-formed, and can also minify XML down to a single compact line for production use.
XML generated by APIs, exported from software, or minified for production is often compressed onto a single line or has inconsistent indentation, making its nested structure hard to follow. Proper formatting — with each element on its own line and consistent indentation reflecting the document's nesting — makes the structure immediately clear, which speeds up debugging, reviewing API responses, and understanding configuration files.
A well-formed XML document follows XML's basic syntax rules: every opening tag has a matching closing tag (or is self-closing), tags are properly nested without overlapping, and there's exactly one root element containing everything else. This tool checks for well-formedness using the browser's built-in XML parser — but note that well-formed is different from "valid against a schema," which would additionally check that the document matches a specific expected structure (defined by a DTD or XSD), something this tool doesn't check.
All formatting, validation, and minification happens directly in your browser — your XML content is never sent to a server.
The formatter first strips out all existing whitespace between tags, collapsing the document to its tightest form, then rebuilds it token by token. Each opening tag increases the indent level for everything nested inside it, each closing tag decreases it back, and self-closing tags stay at the current level without affecting what follows. Elements that contain only a short text value (like <title>Example Book</title>) are kept on a single line rather than being split across three lines, which keeps the output compact and readable instead of needlessly verbose.
Minifying does the opposite: it removes all whitespace sitting between tags, collapsing the document down to the smallest form that's still valid XML. This matters for production use because XML payloads sent over an API or embedded in a build are typically charged or measured by size — stripping the formatting whitespace that only exists for human readability reduces that size with no change in meaning.
<book>...</catalog>.& or < appearing in text content without being escaped as entities.Legacy enterprise systems and SOAP-based APIs frequently exchange data as XML rather than JSON. When debugging a request or response from one of these systems, pasting the raw payload here and formatting it makes the nested envelope, header, and body structure visible at a glance, which is far faster than scanning an unindented wall of tags.
It's worth being clear about what this tool checks: "well-formed" means the XML follows correct syntax (matching tags, proper nesting, one root element). It does not mean the document is "valid" in the stricter sense of conforming to a DTD or XSD schema, which would additionally verify that specific elements, attributes, and their order match a predefined contract. A document can be perfectly well-formed and still fail schema validation if, say, a required attribute is missing.
Several file formats people don't immediately think of as XML are actually built on it under the hood — SVG images, RSS and Atom feeds, and the Office Open XML formats behind modern .docx, .xlsx, and .pptx files are all XML documents with a specific vocabulary of tags. Opening one of these in a text editor usually shows a single unreadable line; running it through this formatter turns it into a structure you can actually inspect, which is useful when debugging a broken SVG icon or a malformed RSS feed.
Manually re-indenting a large XML document — counting nesting levels and adding spaces by hand — is slow and error-prone, especially once a document is more than a few dozen lines. A single miscounted indent doesn't break the XML (since indentation isn't meaningful to the parser the way it is in YAML), but it does make the document harder to read for anyone who opens it next. Running it through this tool fixes the whole document's indentation consistently in one pass.
The formatter preserves tag attributes exactly as written — such as the id="1" in <book id="1"> — without reordering or reformatting them, since attribute order can matter for some consumers even though the XML spec doesn't require a specific order. Self-closing tags like <br/> or <item value="x"/> are recognized and kept on their own line at the correct indent level rather than being mistaken for an opening tag awaiting a separate closing tag.