XML Formatter and Validator
Paste messy or single-line XML and instantly get a clean, readable version with proper indentation, or minify it to reduce its size. Before formatting, it checks that the XML is well-formed: if something is wrong (an unclosed tag, incorrect nesting, or an invalid entity), it shows you the exact line and column. Attributes, comments and CDATA sections are preserved. Everything happens in your browser: your XML is never uploaded to any server.
How to format XML
- Paste your XML into the box on the left.
- Choose “Format” to beautify it with indentation, or “Minify” to compress it into a single line.
- If formatting, adjust the indent size (2 spaces, 4 spaces or tab).
- The result appears instantly on the right; copy it with “Copy” or download it as .xml. If the XML has an error, you will be shown where.
Frequently asked questions
What does an XML formatter do?
It rewrites an XML document with consistent line breaks and indentation to make it readable, without changing its content. It can also do the opposite: minify it, removing unnecessary spaces and line breaks to reduce its size. It is useful for reading, reviewing or debugging XML that is hard to follow.
Is my XML uploaded to a server?
No. Both validation and formatting happen entirely in your browser using JavaScript; your XML never leaves your device, and the tool works offline once it has loaded. It is safe for files containing sensitive data.
Does it validate the XML?
Yes. Before formatting, it checks that the XML is well-formed using the browser’s native XML parser: it detects incorrectly nested or unclosed tags, malformed attributes and invalid entities, and points out the line and column of the error. It does not validate against a DTD or an XSD schema; it checks well-formedness, which is what a formatter needs.
Can I minify XML?
Yes. The “Minify” mode removes the whitespace between tags and the line breaks, leaving the XML on a single line. It is useful for reducing the size of a config file or a response before sending or storing it.
Does it preserve comments and CDATA sections?
Yes. Comments (<!-- … -->), CDATA sections (<![CDATA[ … ]]>) and the XML declaration (<?xml … ?>) are preserved. Formatting only changes spacing and indentation, never the content.
Does it work with SVG, RSS or configuration files?
Yes. It works with any well-formed XML: SVG images, RSS or Atom feeds, Maven’s pom.xml, sitemaps, web.config, plist files, SOAP responses, Android layouts and more. Since SVG and RSS are also XML, this tool beautifies them the same way.
Does formatting change the meaning of the XML?
No. It only rearranges whitespace and line breaks. Tags, attributes, text, comments and CDATA sections are all kept intact. Keep in mind that, in XML, whitespace inside text can be significant; that is why the content of each element is never altered.