XML Formatter & Validator
Beautify, minify, and validate XML entirely in your browser. Nothing is uploaded.
What this tool does
Takes any XML string and pretty-prints it with clean indentation, or collapses it down to a single compact line. Before it does either, it checks that the XML is well-formed using the browser's built-in DOMParser. If the syntax is broken, you get a clear error instead of a false "success" and mangled output. Everything happens in your browser: the input never leaves the page, never gets uploaded, never gets logged.
How to use it
Paste your XML into the input box. To read it, pick an indent style (2 spaces is the default) and press Beautify. To shrink it for storage or transport, press Minify. If the document is not well-formed, the status line shows the parser's complaint so you can find the problem. Use Copy result to grab the output.
Example: paste <a><b>x</b></a> and press Beautify to get a nested,
indented result. Paste <a><b></a> and you get a parse error, because the
tags are closed in the wrong order.
Common use cases
- Reading a minified SVG, RSS feed, or sitemap that arrived on one line.
- Reformatting a SOAP or REST XML payload copied from a network tab.
- Checking whether a hand-edited config file is still well-formed before shipping it.
- Shrinking an XML document for storage or transport with Minify.
- Spotting a mismatched or wrongly-nested tag in a large document.
Common pitfalls
- Well-formed is not the same as valid. This tool checks syntax only. It does not validate against a DTD or XML Schema, so a document can pass here and still break a schema-aware consumer.
- Whitespace can be significant. XML keeps whitespace inside elements by default. If an element mixes text with child elements, adding indentation can change meaning. The tool skips reindenting text-bearing elements, but review output when spacing matters.
- Reserved characters must be escaped. A bare
<or&inside text content is a parse error. Write them as<and&, or wrap the text in a CDATA section. - One root element only. XML allows exactly one top-level element. Two
siblings at the root (for example
<a/><b/>) will not parse.
Frequently asked questions
- What does "well-formed" XML mean?
- Well-formed XML follows the basic syntax rules: every start tag has a matching end tag, tags are properly nested, attribute values are quoted, and there is exactly one root element. This tool checks well-formedness using the browser DOMParser. It does not validate against a DTD or XML Schema, so it will not tell you whether the document matches a specific grammar; it only tells you whether the syntax is legal.
- Why does my XML report a parse error?
- The browser DOMParser found a syntax problem. Common causes: a start tag with no matching end tag, tags closed in the wrong order (such as <a><b></a>), an unquoted attribute value, a stray "less-than" or ampersand that should be escaped, or more than one root element. The tool surfaces the parser message, which usually points at the line or reason so you can locate the fault.
- Does Beautify change the meaning of my XML?
- Pretty-printing adds newlines and indentation between elements to make structure readable. For most documents this is safe, but XML treats whitespace inside elements as significant by default. If an element carries text mixed with child elements (mixed content) or relies on exact whitespace, added indentation can change what the document means. The tool avoids reindenting elements that contain text, but review the output when whitespace matters.
- What does Minify do to XML?
- Minify collapses insignificant whitespace between tags: the newlines and indentation that sit between one element and the next. It leaves text content, attributes, and CDATA sections untouched. The result is a single compact string that takes less storage and less bandwidth while parsing to the same document tree.
- Is the XML I paste here uploaded anywhere?
- No. The tool runs entirely in your browser using the built-in DOMParser and XMLSerializer. Your input is never sent to a server. Once the page has loaded you can disconnect from the network and it still works.
- Does this tool preserve attribute order?
- Yes. The DOMParser keeps attributes in the order they appear in the source, and the tool serializes them in that same order. Note that XML itself treats attribute order as insignificant, so a strict comparison against another document should not depend on it.
- Can it format an entire SVG or RSS feed?
- Yes. SVG images, RSS and Atom feeds, sitemaps, SOAP envelopes, and configuration files are all XML, so they beautify and minify the same way. Very large documents are still handled in-browser, though extremely large files may format more slowly on low-powered devices.
Cite this tool
For academic, journalistic, or technical references. Pick a format:
Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.