We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.
by Cosmovex
Format and beautify XML, minify XML, validate XML syntax, convert XML to JSON, and run XPath queries. No signup required.
The XML Formatter & Validator takes raw XML and pretty-prints it with consistent indentation, so a single-line config dump or a wall of unbroken markup becomes a readable, nested tree. It also checks the document for well-formedness: it confirms that every tag is closed, that elements nest correctly, that attribute quoting is valid, and that the document has a single root. If something is off, it points you at the problem instead of failing silently.
It runs entirely in your browser. Paste or drop a file in, and the parsing, formatting and validation all happen locally on your machine. Nothing is sent to a server, which matters when the XML is an API response with a session token, a SOAP envelope, a build manifest, or anything else you would rather not upload. There is no account, no rate limit, and you can keep working with the page open offline once it has loaded.
Paste XML into the input, drop a file, or type directly. The tool parses the markup into a node tree and re-serializes it, which is what produces clean output rather than a naive find-and-replace on angle brackets. Core actions:
&) so you can jump straight to it.Because it works on the parsed tree, the formatter preserves attribute values, CDATA sections, comments, and the XML declaration rather than mangling them.
Say an API returns this on one line:
<order id="42"><item sku="A1">Pen</item><item sku="B2">Notebook</item></order>
Beautifying it with 2-space indentation gives you something you can actually read:
<order id="42">
<item sku="A1">Pen</item>
<item sku="B2">Notebook</item>
</order>
Now drop a closing tag:
<order id="42">
<item sku="A1">Pen
<item sku="B2">Notebook</item>
</order>
Validation flags it: the parser expected </item> but found <item>, so the first item is never closed. The fix is to add the missing </item>. This is the most common class of XML bug, and seeing the document indented makes the unbalanced nesting obvious at a glance.
pom.xml, Android AndroidManifest.xml, .csproj, web config, and similar files are easier to review and diff when consistently indented.A few things that trip people up:
& is an error; write &. The same goes for < and > inside element content, which become < and >.< or & (for example, an HTML snippet), wrap it in <![CDATA[ ... ]]> so the parser treats it as raw text.<?xml ... ?> line or your <!-- notes -->.XML has two distinct correctness levels, and it helps to know which one you are getting.
Well-formedness is the baseline every XML document must meet. The rules are purely structural: one root element, every start tag has a matching end tag (or is self-closing like <br/>), elements nest without overlapping, attribute values are quoted, attribute names are unique within an element, and special characters are escaped. A document that breaks any of these cannot be parsed at all. That is what this tool verifies.
Validity is a stronger, optional guarantee: the document is well-formed and it conforms to a grammar declared in a DTD or XML Schema (XSD) — correct element order, required attributes, allowed data types, and so on. Checking validity requires the schema, which lives outside the document.
In practice, well-formedness catches the overwhelming majority of everyday XML mistakes (typos, unclosed tags, stray ampersands). Reach for a schema validator only when you need to enforce a specific contract.
No. It checks well-formedness (correct XML syntax: matched tags, proper nesting, quoting, a single root). It does not validate against a DTD or XSD, which would require you to supply that schema.
No. Parsing, formatting, and validation all run locally in your browser. The XML never leaves your machine, so it's safe to paste responses that contain tokens or private data.
`&` starts an entity reference in XML, so a bare ampersand is invalid. Replace it with `&`. Likewise use `<` for `<` and `>` for `>` inside element content.
An XML document must have exactly one top-level element. If you have two or more elements at the outermost level, wrap them in a single parent element to make it well-formed.
Beautify adds line breaks and indentation so the document is human-readable. Minify removes insignificant whitespace between elements to make the payload smaller for transport or storage.
No. It re-indents the markup but preserves attribute values, text content, CDATA sections, comments, and the XML declaration. Only whitespace between elements changes.
Yes. Self-closing (empty) elements such as `<br/>` or `<item id="1"/>` are valid XML and are preserved as-is during formatting.
Prefixed element and attribute names are treated as ordinary names for well-formedness, so namespaced documents format and validate fine. It checks syntax, not whether each prefix is bound to a declared namespace.