What is the XML Formatter?
XML is still everywhere: SOAP APIs, RSS and Atom feeds, sitemaps, SVG images, Android layouts, Maven pom.xml files and Microsoft Office documents. This XML formatter takes compact or badly indented XML and pretty-prints it with one element per line and consistent indentation.
It also works as an XML validator. Your browser's XML parser checks that the document is well-formed: tags are properly nested and closed, attributes are quoted, and there is a single root element. If it isn't, you get the parser's message with the line and column. Comments, CDATA sections, processing instructions, namespaces and the XML declaration are all preserved. Minify removes the whitespace between tags for the smallest possible file.
How to use the XML Formatter
- Paste your XML, or click Sample to see an example.
- Click Format to pretty-print, Minify to compress, or Validate to only check the syntax.
- If there is an error, fix the line and column shown in red and try again.
- Copy the result or download it as an
.xmlfile.
Frequently asked questions
What is the difference between well-formed and valid XML?
Well-formed XML follows the basic syntax rules (matching tags, quoted attributes, one root element). Valid XML is also well-formed but additionally matches a schema (XSD or DTD). This tool checks well-formedness, which catches the vast majority of real-world errors.
Does formatting change my data?
Only whitespace between elements changes. Elements that contain text keep that text exactly. If your format treats whitespace as significant (for example xml:space="preserve"), check the result before using it.
Can I format SVG files?
Yes. SVG is XML, so paste the SVG markup to format or minify it.