XML Formatter and Validator
Format, validate and minify XML in your browser. Native well-formedness checking with error location, clean indentation, CDATA preserved. Free.
About the XML Formatter and Validator
This XML formatter indents and pretty-prints XML documents so their structure is clear, validates them for well-formedness, and can minify them back down. Paste a config file, an API response or an RSS feed, choose your indentation, and get tidy XML ready to copy or download.
Validation uses the browser's native XML parser, so it accurately catches real well-formedness errors — mismatched tags, unescaped characters, missing quotes — and reports where the problem is. Formatting keeps single-value elements inline (<title>Dune</title>) while expanding nested structures, and preserves CDATA sections and processing instructions exactly.
The Minify option strips insignificant whitespace and comments to produce the smallest valid document, showing the byte savings. Everything runs locally in your browser, making it safe for internal configs and private feeds. It works offline once loaded.
How to Use the XML Formatter and Validator
- 1Paste your XML into the input box.
- 2Choose 2 spaces, 4 spaces or tabs for indentation.
- 3Click Format to beautify, Minify to compress, or Validate to check it.
- 4Fix any reported error, then copy or download the result.
Frequently Asked Questions
What does 'well-formed' XML mean?
Well-formed XML follows the basic syntax rules: every tag is closed, elements nest properly, attribute values are quoted, and special characters are escaped. This tool checks well-formedness with the browser's XML parser. It does not validate against a DTD or XSD schema, which is a separate, stricter check.
Does formatting preserve CDATA and comments?
Formatting preserves CDATA sections and processing instructions exactly, and keeps comments. Minifying removes comments (since they're not needed at runtime) but still preserves CDATA content, which is significant data.
Why does an element stay on one line while others expand?
Elements whose only content is text — like <title>Dune</title> — are kept inline for readability, while elements that contain child elements are expanded with indentation. This mirrors how developers naturally format XML.
How is XML different from HTML formatting?
XML is stricter: all tags must be closed and case matters, so the parser can reliably validate it. HTML tolerates unclosed tags and has void elements. Use this tool for XML, config files and feeds; use the HTML Formatter for web markup.