XML Formatter
Paste XML to indent it neatly or squeeze it onto one line. Comments, CDATA sections and processing instructions stay exactly as they are, and errors are pointed out with their line and column.
INPUT
OUTPUT
Runs entirely in your browser. Nothing you enter is sent to a server.
How to format XML
Paste or open the XML
Paste a configuration file, a feed, an API response or an SVG, or open a file from your device.
Choose the layout
Pick Format with 2 spaces, 4 spaces or tabs, or Minify to remove the whitespace between tags. Sort attributes A–Z if you want to compare two files.
Copy or download
Copy the result or download it as an .xml file.
Only the whitespace between tags changes
The formatter checks the XML with your browser's parser first, then re-indents it from the original text. Entity references, attribute quotes, comments, CDATA and processing instructions are written back unchanged. Elements that contain text, or text mixed with tags, are left as written, so no meaningful spaces are added or lost.
Finding the error in broken XML
An unclosed tag, a tag name that doesn't match, an unescaped & or a second root element makes XML invalid. The message shows the line and column where the parser stopped, with the line itself underneath.
Frequently asked questions
Is my XML uploaded anywhere?
No. Checking and formatting happen in your browser, so files with internal data never leave your device.
Does it validate against a schema (XSD or DTD)?
No. It checks that the XML is well-formed: tags are closed and nested correctly, attributes are quoted and there is one root element. It doesn't check the document against a schema.
Is xml:space="preserve" respected?
Yes. Elements with xml:space="preserve" keep their content exactly as written, in both Format and Minify.