Command Palette

Search for a command to run...

XM

XML Formatter

Format, beautify, minify, and validate XML online - preserves comments, CDATA, and attribute order, with clear error reporting

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 &amp; 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 &amp; 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?

  1. 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.

  2. 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.

  3. 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.

  4. 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

Paste your XML into the input panel, choose Beautify, pick an indentation width, and click Format. The tool parses the document, re-indents it, and lets you copy or download the result. All processing happens in your browser - nothing is uploaded.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

xml formatterxml beautifierformat xmlxml pretty printxml minifierxml validatorbeautify xmlxml formatter onlineindent xmlonline xml formatterxml formatter free