XML Formatter
Pretty-print or minify XML, well-formedness checked.
Format (pretty-print) or minify XML online with consistent indentation, preserving comments, CDATA, processing instructions and the XML declaration. Mismatched or unclosed tags are flagged with the line and column. Works on SVG, RSS and sitemaps. Runs fully in your browser.
How to use XML Formatter
Paste your XML
Paste your XML into the input pane or upload an .xml, .svg or .rss file to format online instantly in your browser, with nothing uploaded.
Pick indentation
Choose 2 spaces, 4 spaces or tabs so the free XML formatter pretty-prints nested elements with the consistent spacing your project style needs.
Toggle minify
Leave minify off to beautify and indent the XML, or switch it on to strip whitespace and collapse the document to a compact single line.
Check well-formedness
The XML formatter validates well-formedness first and flags any mismatched or unclosed tag with the exact line and column so you can fix it fast.
Format instantly
The formatted XML appears instantly in the output pane, with comments, CDATA and the XML declaration preserved exactly as written.
Copy or download
Copy the formatted XML to your clipboard with one click or download it as a ready-to-use .xml file straight from your browser.
Frequently asked questions
Does formatting change my XML's meaning?
It only changes layout whitespace between elements. Element names, attributes, text content, CDATA and comments are preserved. Note that insignificant whitespace inside mixed content may be normalised — for data/config XML this is exactly what you want.
What does “well-formed” mean?
Well-formed XML follows the syntax rules: one root element, every tag closed, tags properly nested, and attributes quoted. This tool checks well-formedness (not validation against a DTD or XSD schema) and reports the first error's location.
Can it format SVG, RSS or sitemap files?
Yes — those are all XML, so they format the same way. Upload a .svg, .xml or .rss file, or paste the markup. Everything is processed locally in your browser.
How do I format or beautify XML online for free?
Paste your XML into this free online XML formatter, choose your indentation, and it pretty-prints the document instantly with nested elements neatly indented. It runs entirely in your browser, so there's no sign-up and nothing is uploaded.
How do I minify XML to reduce file size?
Turn on the Minify option and the XML formatter strips out the formatting whitespace between elements, collapsing the document to a compact single line that's smaller and faster to transport. Switch Minify back off to pretty-print and beautify it again.
Why does the XML formatter say my document is not well-formed?
The tool checks well-formedness before formatting, so a mismatched, unclosed or wrongly nested tag, or an unquoted attribute, will stop it and report the exact line and column of the first error. Fix that spot and the XML will format correctly.
Is my data sent to a server?
No. The XML is parsed and re-formatted entirely in your browser. Nothing is uploaded, logged or stored.
Can it format a sitemap.xml or RSS feed?
Yes — sitemaps, RSS and Atom feeds are all XML, so paste or upload the file and it pretty-prints the tags with clean nesting. It's handy for reading a large auto-generated sitemap or checking a feed's structure by eye.
What's the difference between an XML formatter and an XML validator?
A formatter re-indents the XML to make it readable (and can minify it), while a validator only checks correctness. This formatter does both: it verifies the document is well-formed first, reporting any error's line and column, then formats it.
Related tools — Formatters & validators
- JSON Formatter — Beautify or minify JSON with live error checking.
- JSON Validator — Validate JSON and pinpoint syntax errors.
- XML Validator — Check XML is well-formed and locate errors.
- YAML Formatter — Tidy YAML or convert it to JSON.
- SQL Formatter — Standardise SQL with dialect-aware formatting.
- SQL Beautifier — Turn cramped one-line SQL into readable queries.