XML Formatter
Paste XML to indent it neatly, squeeze it onto one line, or find out exactly where it is broken.
Comparing two versions? Format both, then use the XML diff checker.
Why format XML?
SOAP responses, sitemaps, RSS feeds, Android resources and exported config files often arrive as one long line, or with indentation that drifted after years of hand edits. Reformatting puts every element on its own line and indents children under their parent, so you can see the structure and spot a missing or misplaced tag.
The formatter also checks that the XML is well formed. It parses your text with the browser's own XML parser (DOMParser), which does not download external DTDs, external entities or any other remote URL, and nothing you paste is sent to a server.
Example: a one-line order
An order exported as a single line:
<order id="1001" date="2026-11-16"><customer>Ali Raza</customer><items><item sku="PEN-01" qty="2">Blue pen</item><item sku="NB-05" qty="1">A5 notebook</item></items><total currency="PKR">850</total></order>After clicking Beautify:
<order id="1001" date="2026-11-16">
<customer>Ali Raza</customer>
<items>
<item sku="PEN-01" qty="2">Blue pen</item>
<item sku="NB-05" qty="1">A5 notebook</item>
</items>
<total currency="PKR">850</total>
</order>The two <item> elements now sit side by side under <items>, and elements that only hold text, such as <customer>, stay on one line so their content is not changed.
How to format XML
- Paste your XML into the box, or click Open file to load an .xml file from your computer.
- Click Beautify for indented output, or Minify to remove the whitespace between tags. Sample loads an example and Clear empties both panes.
- If the XML is broken, read the error and go to the line and column it names.
- Copy the result, or download it as formatted.xml.
To compare two versions of a file after formatting both, use the XML diff checker.
Frequently asked questions
- What is the difference between beautify and minify?
- Beautify puts each element on its own line and indents it by two spaces per level, which makes the file easy to read and to compare. Minify removes the whitespace between tags so the document is as small as possible for sending or storing. Text inside elements is left alone in both modes.
- What happens if my XML is invalid?
- Nothing is formatted. Instead you see the parser's error message and, when the browser reports it, the line and column where parsing stopped. Common causes are a closing tag that doesn't match its opening tag, an unescaped & or <, an attribute value without quotes, or two root elements.
- Is my XML sent to a server?
- No. Parsing and formatting run in your browser. The XML never leaves your device, and the parser does not fetch DTDs, external entities or other URLs mentioned in the document.
- Are comments, CDATA sections and the XML declaration kept?
- Yes. Comments, CDATA sections, processing instructions and the <?xml ... ?> declaration are kept in both beautified and minified output.