What the XML Formatter does
XML is everywhere developers may not expect it: RSS and Atom feeds, SOAP API responses, SVG graphics, Android layout files, Maven pom.xml builds, Office Open XML documents, sitemaps, and configuration for countless frameworks. The trouble is that XML is frequently produced by machines on a single line, with no whitespace, which makes it almost impossible to read or debug by eye. This formatter takes that compact, machine-generated XML and re-indents it into a clean, nested tree so you can actually see the structure, find the element you care about, and spot where a tag was never closed.
It does three jobs from one input box. Format rebuilds the document with the indentation you choose (2 spaces, 4 spaces, or tabs) and puts each element on its own line. Minify does the opposite: it strips insignificant whitespace between tags to produce the smallest valid payload, which is useful before sending XML over the wire or embedding it in another file. Validate runs the input through the browser’s XML parser and reports the first well-formedness error it finds, including the kind of problem and roughly where it occurred.
How to use it
- Paste your XML into the input box, or press Load sample to try it with a small example document.
- Pick your indentation in the Indent dropdown. Two spaces is common for feeds and config; four spaces or tabs suit larger documents.
- Press Format to pretty-print, or Minify to collapse it to one line.
- If the parser reports a problem, read the message under the buttons — it tells you whether a tag is unclosed, mismatched, or contains an illegal character.
- Press Copy to put the result on your clipboard, then paste it into your editor, ticket, or commit.
Well-formed vs. valid XML
It helps to know the difference. Well-formed XML follows the basic syntax rules of the language: one root element, every opening tag has a matching closing tag, attributes are quoted, and special characters such as & are escaped. Valid XML is well-formed and conforms to a schema (a DTD or XSD) that defines which elements and attributes are allowed and in what order. This tool checks well-formedness, which is the error that breaks parsers most often. It does not validate against a custom XSD, because schemas are project-specific and usually live on your build server.
Common XML mistakes this tool catches
- Unclosed or mismatched tags — for example
<item>...</Item>where case does not match. - Multiple root elements — XML allows exactly one top-level element.
- Unescaped ampersands — a bare
&in text must be written as&. - Stray characters before the declaration — the
<?xml ?>declaration must be the very first thing in the file.
Frequently asked questions
Is my XML uploaded anywhere?
No. Formatting, minifying and validation all happen in your browser with the native DOMParser and XMLSerializer. The XML never leaves your device, which makes the tool safe for configuration files and API responses that may contain internal details.
Can it validate against my XSD or DTD?
Not currently. It checks that your XML is well-formed (correct syntax, matched tags, single root). Schema validation requires your specific XSD/DTD and is usually run as part of a build pipeline rather than a quick browser tool.
Why did formatting change my self-closing tags?
The browser normalises XML when it parses it. Empty elements such as <br></br> may be re-serialised as <br/>. The two forms are equivalent in XML. Enable “Collapse empty tags” to prefer the self-closing form.
Does it handle very large files?
It can handle most documents that fit comfortably in memory, but extremely large files (tens of megabytes) may be slow because the entire document is parsed at once. For huge feeds, format a representative sample instead.
