About Format XML
Format XML is a free browser tool that re-indents XML into a readable tree, squeezes it back onto one line, and tells you where the markup breaks. This page explains what the parser does step by step, which parts of your document it promises not to touch, and where the work happens.
What it does
Two modes, one toggle. Beautify gives every node its own line and indents it by depth, using 2 spaces, 4 spaces, or a tab — whichever your project uses. An element whose entire content is a short piece of text stays on one line, so a list of <price> values reads as a column instead of sprawling over three lines each. Minify removes the line breaks and indentation again and returns the document as a single line, which is what you want in a request body or a test fixture.
Either mode can strip <!-- … --> comments on the way through. Documents up to 5 MB — around 150,000 lines — are accepted, and the result can be copied to the clipboard or saved as a file.
How it works technically
The document goes through a purpose-built XML parser rather than the browser's own DOMParser, because a formatter needs things the built-in parser does not hand back: the position of an error, the original attribute order, and tolerance for fragments. Three passes run over your input:
- Scan. The source is walked once, character by character, splitting it into tags, text, comments, CDATA sections, processing instructions and the DOCTYPE. Quoting is respected while scanning, so a
>inside an attribute value does not end a tag early, and a DOCTYPE with an internal subset in square brackets is read whole. - Nest. Opening tags go on a stack and closing tags pop it. A tag that closes the wrong element, a closing tag with nothing open, or an element still open at the end of the document each stop the run with a message that carries the line, the column, and the line where the mismatch started.
- Print. The tree is written back out at the indentation you picked, or with no whitespace at all in Minify mode. Because printing works from the parsed tree and not from a pile of regular expressions, deeply nested documents come out correctly aligned however messy the input was.
Attribute values are checked as they are read, which is where most real-world breakage turns up: a value with no quotes, an attribute with no value at all, or the same attribute written twice on one element are each reported by name.
What is preserved
Formatting should change the layout of a document and nothing else, so the printer copies through the parts that carry meaning: the XML declaration and its encoding, the DOCTYPE, processing instructions, namespace prefixes, CDATA blocks byte for byte, and entities such as & or é, which are never re-escaped into something subtly different.
Attributes keep the order you wrote them in and the quote character you used, so href='/a' does not silently become href="/a" and diffs stay small. An empty element written as <br/> stays self-closing, while one written as <br></br> keeps its pair of tags.
Where the work happens
The scan, nest and print passes above all run inside the tab you have open. Your markup is not uploaded, not logged, and not stored — there is no server behind this page doing the formatting, only a JavaScript file your browser already downloaded.
Two consequences follow. The tool keeps working with the network disconnected, because there was never a round-trip to wait for. And when you close the tab or clear the editor, the document goes with it: nothing is written to storage on your device, so nothing about it survives to your next visit.
This describes what Format XML does with your document. It says nothing about what a browser extension, a corporate proxy, or the machine itself might see — only that this site adds nothing to that list.
Got XML to clean up?
Open the XML formatter and paste it in — the result appears as you type.