How to use the XML Formatter
- Paste your XML into the left box, or open a file.
- Adjust the options if you need to.
- Copy the formatted XML or download it as a file.
What does this tool do?
Your browser's XML parser checks that the document is well-formed (every tag closed, attributes quoted, one root element). Comments, CDATA sections and processing instructions are preserved.
What formatting changes, and what it drops
Beautify puts each element on its own line, indented by 2 spaces, 4 spaces or a tab, and trims spaces around text. That is safe for data files such as sitemaps and feeds. In documents that mix text and tags, such as <p>Hello <b>world</b></p>, the text and the tag each end up on their own line, which can change how the spaces between words are read. Check mixed content by eye.
The XML declaration (<?xml … ?>), comments and CDATA sections are kept. A DOCTYPE line is dropped from the output, so a document that depends on a DTD needs it added back by hand.
Related: XML to JSON converter · JSON to XML converter · HTML formatter
What Minify does
Minify removes the whitespace between one tag and the next and trims the ends, nothing more. It does not shorten names or strip comments. It also works on the text exactly as typed, so spaces between tags inside a comment or CDATA block are removed too. Beautify the XML first if it is invalid, because Minify only runs on XML that passed the well-formed check.
Well-formed is not the same as valid. This tool checks the syntax rules only, not an XSD or DTD schema.
Why use it?
- Read sitemaps, feeds and SVG files.
- Spot unclosed tags.
- Minify XML for transport.
Worked example: a one-line feed made readable, and one that fails
Pasted on one line: <feed><entry id="1"><title>Hi</title><tags/></entry></feed>. With 2-space indent the output is six lines, with <title>Hi</title> kept on a single line and <tags/> left self-closing. Now remove the closing </title>: the tool refuses to format and shows the browser parser's message about the mismatched tag instead.
| Input problem | Result |
|---|---|
| Unclosed or mismatched tag | Error message, nothing formatted |
| Two root elements | Error message (only one root is allowed) |
| Attribute without quotes | Error message |
| Unescaped & in text | Error message; write & instead |
Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Frequently asked questions
Can formatting change what my XML means?
Usually not, but in documents that mix text and tags (like XHTML or DocBook), added whitespace can show up in the text. For data files — feeds, configs, API payloads — formatting is safe.
How do I find what's wrong with invalid XML?
The formatter shows the parser's error. The most common causes are an unclosed tag, an unescaped & character, unquoted attribute values, or more than one root element.
Content last updated . See how M2Toolkit works.