XML Formatter & Minifier

Beautify or minify XML, and validate that it's well-formed.

The XML Formatter beautifies dense or minified XML into clean, indented markup — and can minify it back down for transport. It parses your document with the browser's XML engine, so it also tells you when the XML isn't well-formed, pointing at the parse error. Attributes, comments, and CDATA sections are preserved.

  • Beautify with 2 or 4-space indentation, or minify
  • Validates well-formedness and reports parse errors
  • Keeps attributes, comments, and CDATA
  • 100% private — nothing is uploaded

Well-Formed vs Valid XML

This tool checks that XML is well-formed— properly nested tags, quoted attributes, a single root element — which is what a parser requires to read it at all. That's different from being valid against a DTD or XSD schema. To move between formats, see XML to JSON and JSON to XML.

How to Use It

  1. 1Paste minified or inconsistently-indented XML into the input.
  2. 2Click Beautify for readable, indented output, or Minify to strip whitespace for transport.
  3. 3If the document isn't well-formed, the parser's error is shown instead of a broken result — fix the reported issue and reformat.
  4. 4Copy the output back into your file, request body, or config.

Well-Formed vs Valid XML

This tool checks that XML is well-formed— properly nested tags, quoted attributes, a single root element — which is what a parser requires to read it at all. That's different from being valid against a DTD or XSD schema. To move between formats, see XML to JSON and JSON to XML.

Common XML Mistakes This Catches

  • Unclosed or mismatched tagsEvery opening tag must have a matching closing tag in the right order — the parser error points to exactly where nesting breaks.
  • Unquoted attribute valuesUnlike HTML, XML always requires quotes around attribute values (id="1", not id=1) — this is one of the most common well-formedness failures.
  • Multiple root elementsAn XML document must have exactly one top-level element; a second sibling at the root level fails to parse.
  • Unescaped special charactersA raw & or < inside text content must be escaped as &amp; or &lt; — otherwise the parser reads it as the start of a new tag or entity.

Common Uses

  • Reading API responsesPretty-print a minified SOAP or REST XML response so you can inspect its structure.
  • Config and build filesTidy pom.xml, web.config, or Android layout files for readable diffs.
  • RSS and sitemapsFormat feed and sitemap XML and confirm it parses before publishing.
  • Minifying for transportStrip whitespace to shrink XML payloads sent over the wire.
  • Debugging SOAP requestsBeautify a raw SOAP envelope to read the nested body and headers clearly.

Frequently Asked Questions

It checks well-formedness — correct nesting, quoting, and a single root — using the browser's XML parser, and reports an error if the document can't be parsed. It does not validate against a DTD or XSD schema.

Yes. Comments and CDATA sections are kept in the formatted output, and attributes are preserved on every element.

Yes. The Minify option removes insignificant whitespace between elements to produce a compact single-line document.

No. Parsing and formatting happen entirely in your browser. Nothing is sent to a server.

Well-formed means the XML follows basic syntax rules (matched tags, quoted attributes, one root) and can be parsed at all. Valid means it additionally conforms to a specific DTD or XSD schema's rules — a document can be well-formed but still invalid against a particular schema.

Yes — namespaced elements and attributes (like <ns:tag> or xmlns declarations) are preserved exactly as written through formatting and minification.

Related Tools