What is XML Formatter?
XML Formatter is a tool that reads any XML document and rewrites it with clean, consistent structure. Paste a minified or messy XML payload - a SOAP envelope, an RSS feed, a Maven pom.xml, an Android layout, a sitemap - and get back readable, properly indented markup, or collapse a formatted document down to a single compact line when you need the smallest possible size.
Here is the online XML formatter on a small payload. Paste <note><to>Ana</to><body>Hi & bye</body></note>, keep Beautify and 2 spaces, and press Format. The output puts <to> and <body> on their own lines, indented two spaces inside <note>, and the header reads "3 elements · 4 lines · 57 bytes". Switch to Minify and press it again, and the same document is back on one line at 50 bytes. The & stays exactly as written. This XML formatter is free, no signup, and there is no upload step.
Raw XML from APIs, build tools, and exports often arrives on one enormous line, or with mixed tabs and spaces that make it impossible to scan. Beautifying it reveals the element hierarchy so you can find the node you need, spot a missing tag, or diff two versions. Minifying does the reverse - stripping the whitespace between tags to shrink a config file or a request body without changing its meaning. This tool does both, and checks the tag structure along the way so unclosed and mismatched tags are caught before they reach your parser.
Everything runs 100% in your browser using a dependency-free parser - no DOMParser, no server round trip. XML documents frequently carry configuration, integration payloads, or internal identifiers, so nothing you paste is uploaded or stored. Comments, CDATA sections, the XML declaration, and your original attribute order are all preserved, and the tool keeps working offline once the page has loaded.
Formatting preserves what carries meaning and normalises what does not. Attribute order is kept, because although XML treats it as insignificant, diff tools and reviewers do not. CDATA sections and comments survive untouched. Whitespace is where you need to be careful. In XML a space between text and a child element is part of the document, not layout, and this formatter does not special-case it: leading and trailing spaces in every text node are trimmed, and mixed content such as <p>Hello <b>world</b> again</p> is split so each piece sits on its own line, while Minify joins the pieces with no spaces at all. Leave prose-style markup like that unformatted.
How to use XML Formatter?
Paste your XML
Paste any XML document into the input panel - minified, indented, or somewhere in between - or click Load Sample to start from a realistic catalog example with attributes, a comment, and a CDATA block.
Choose format or minify
Pick Beautify to pretty-print with 2-space, 4-space, or tab indentation, or Minify to strip all insignificant whitespace into one compact line.
Set your options
Optionally self-close empty elements, sort each element’s attributes alphabetically, or remove comments. The document is parsed and validated first, so malformed markup is reported with the line number.
Copy or download the result
Copy the formatted XML to your clipboard or download it as a .xml file, then drop it into your editor, request body, or config.
Key Features
Beautify and Minify
Pretty-print XML with configurable indentation for readability, or minify it to the smallest whitespace-free form - both from the same tool
Comment and CDATA Preservation
XML comments, CDATA sections, the XML declaration, and processing instructions are kept intact, so formatting never loses information
Attribute Order and Quoting Kept
Attributes keep their original order and quote style by default, with an optional alphabetical sort when you want a canonical ordering
Built-in Validation
Broken structure - an unclosed tag, a mismatched closing tag, an unterminated comment or CDATA - is caught with a specific error, most of them with a line number
Frequently Asked Questions
Related Tools
JSON to XML
Convert JSON to well-formed XML instantly. Map object keys to elements, @-prefixed keys to attributes and #text to content, expand arrays into repeated tags, and export minified or pretty-printed XML. 100% client-side.
JSONPath Tester
Test JSONPath expressions against any JSON and see the matched values and their paths instantly. Supports wildcards, recursive descent, slices, and filters. 100% client-side.
XML to JSON Converter
Convert XML to clean, valid JSON instantly - handles attributes, nested elements, repeated tags, and CDATA
XML Diff Checker
Compare two XML documents structurally and see which elements, attributes, and text values were added, removed, or changed, by node path rather than by line. 100% client-side.
Comments
0 comments
No comments yet. Be the first to share your thoughts!