XML Formatter, Validator & Minifier

Format, validate, minify and convert XML. Runs in your browser; nothing is uploaded.

How to format, validate and minify XML

  1. Paste your XML into Input, open an .xml file (or .svg, .rss, .plist, .csproj), or click Sample.
  2. Syntax is checked automatically as you type. Any well-formedness error is underlined directly in the input and described with its exact line and column number.
  3. Choose your indentation (2 spaces, 4 spaces, or tabs) and click Format to pretty-print the markup, or click Minify to strip whitespace between tags. Then copy or download the result.
  4. Switch the output pane to Tree to explore deeply nested XML: click any element to collapse or expand its children, or use Expand all and Collapse all.

Why use this XML formatter and validator?

  • Preserves every XML construct: comments (<!-- ... -->), <![CDATA[...]]> sections, processing instructions, DOCTYPE declarations, and the <?xml version="1.0"?> prolog are kept intact.
  • Compact leaf elements: elements that contain only text (such as <title>Clean Code</title>) remain on a single line instead of being split across three lines.
  • Handles large XML feeds and configs: sitemaps, RSS/Atom feeds, SOAP payloads, SVG graphics, and Maven pom.xml files are processed in a background Web Worker so the browser stays responsive.
  • 100% private in-browser processing: your XML documents are never uploaded to any server.

XML well-formedness rules and common syntax errors

An XML parser rejects the entire document if even one syntax rule is broken. This validator checks and highlights all XML 1.0 well-formedness requirements:

  • Matching, properly nested tags: every opening tag must have a matching closing tag with the exact same case (<Book> and </book> do not match), or be self-closed (<item/>). Overlapping tags like <a><b></a></b> are invalid.
  • Single root element: every XML document must have exactly one top-level root element that wraps all other elements.
  • Quoted, unique attributes: every attribute value must be enclosed in single or double quotes (id="101"), and an element cannot repeat the same attribute name twice.
  • Escaped special characters: literal ampersands (&) and less-than signs (<) inside text or attribute values must be written as &amp; and &lt;, or wrapped in a <![CDATA[...]]> section.
  • Valid tag and attribute names: names cannot start with a number, punctuation, or the letters xml, and cannot contain spaces.

Frequently asked questions

What is the difference between well-formed XML and schema-valid XML?
Well-formed XML follows all XML 1.0 syntax rules: every tag is properly closed and nested, attributes are quoted and unique, special characters are escaped, and there is a single root element. Schema validation goes a step further by checking element names and data types against an external XSD, DTD, or Relax NG schema. This tool checks XML well-formedness.
Are XML comments, CDATA sections, and declarations kept when formatting or minifying?
Yes. The formatter and minifier preserve the <?xml ...?> prolog, <!-- comments -->, <![CDATA[...]]> blocks, DOCTYPE declarations, and processing instructions while re-indenting or stripping insignificant whitespace between tags.
Is my XML document uploaded to a server?
No. All XML parsing, validation, formatting, minification, and tree rendering run locally inside your browser. Your files and data never leave your device.
How can I convert XML to JSON or CSV?
Use the XML sub-menu above the editor to open the XML to JSON Converter for structured JSON objects or the XML to CSV Converter to turn repeating XML elements into a spreadsheet.