CalcCafe

XML Formatter

Format and indent messy or minified XML into clean, readable markup. It runs entirely on your device — nothing is uploaded.

Example

Input
<a><b>1</b><b>2</b></a>
Output
<a>
 <b>1</b>
 <b>2</b>
</a>

How it works

Your XML is parsed natively and re-serialised with consistent indentation.

Good to know

XML Formatter takes XML that has been collapsed onto a single line, packed together with no whitespace, or indented inconsistently, and rewrites it with one element per line and predictable, nested indentation. It is built for developers, QA engineers, and integration teams who routinely deal with SOAP envelopes, RSS/Atom feeds, sitemaps, Maven POM files, Android layouts, or API responses that arrive as an unreadable blob. Because the whole thing runs in your browser, you can paste production payloads without worrying about them being sent to a server.

Reaching for it is most useful when you are debugging: when a third-party service returns minified XML, when a diff tool shows the entire file as one changed line, or when you need to eyeball the structure of a deeply nested document to find a single misplaced tag. Formatting first makes the hierarchy of parents and children obvious, so you can scan for the node you care about instead of counting angle brackets.

To read the output, follow the indentation as a map of nesting depth: each level of indentation is one level deeper in the element tree, sibling elements line up at the same column, and a closing tag sits at the same indentation as its matching opening tag. The example on this page shows two <b> siblings indented one step inside their <a> parent — that visual alignment is exactly what you are looking for to confirm structure.

One practical caveat: the formatter parses your XML before reformatting it, so genuinely malformed input (an unclosed tag, a stray < character, mismatched names) may fail to format rather than silently "fixing" it. If nothing comes out, treat that as a signal that the document is not well-formed and run it through a validator first. Also remember that re-serialising can normalise insignificant whitespace inside elements, so do not rely on this tool for content where spacing inside text nodes is meaningful.

Frequently asked questions

Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.

People also ask

What is the difference between formatting XML and validating XML?
Formatting only changes how the XML looks by adding indentation and line breaks, while validation checks whether the document is well-formed or conforms to a schema (DTD/XSD). A formatter may refuse to process invalid XML, but it does not tell you which rules a schema requires.
Will formatting XML change the data or the meaning of the document?
No, the elements, attributes, and text content stay the same; only insignificant whitespace between tags is added or normalised. However, whitespace that sits inside a text node can be affected, so spacing-sensitive content may shift.
How do I un-format or minify XML back into a single line?
You use a minifier, which strips the indentation and line breaks that a formatter adds. CalcCafe offers a separate XML Minify tool for that purpose.
Why does my XML fail to format?
It usually means the document is not well-formed, for example an unclosed or mismatched tag, an unescaped & or < character, or more than one root element. Fixing those structural errors, or checking with a validator, typically resolves it.
Can I format very large XML files in the browser?
In principle yes, since the work happens locally, but extremely large files can be limited by your device's memory and may format slowly. Splitting a huge file or using a desktop tool can help with multi-megabyte documents.
What indentation does an XML formatter use, tabs or spaces?
Most browser-based formatters apply a fixed number of spaces per nesting level, commonly two spaces, as shown in the example output on this page. The choice is purely cosmetic and does not affect how a parser reads the file.
Is formatted XML still valid for production use?
Yes, well-formed formatted XML is processed identically by parsers, since the added whitespace between elements is insignificant. The main reason to minify for production is to reduce file size for transmission.

Related tools