About the XML Formatter
Paste XML into the box and pick a mode. Beautify XML puts each element on its own line with two-space indentation, so you can follow the structure. Minify XML squeezes out the whitespace between tags to make the file compact. Typical inputs are API responses, RSS feeds, SOAP messages, sitemaps and SVG code.
The result updates as you type and shows a line, character and size count. A warning appears if a tag is never closed, closed in the wrong order or has no opening tag. Copy the result, or download it as formatted.xml or minified.xml (an SVG drawing downloads as .svg).
How the XML beautifier and minifier work
The formatter reads the text as XML: opening and closing tags, self-closing tags such as <br/>, text, comments, CDATA sections, the <?xml ?> declaration and any DOCTYPE. From those pieces it rebuilds the element tree, so the indentation depends only on how elements are nested, not on the line breaks or spaces you pasted. Messy, half-indented XML comes out evenly indented in one step.
Beautify writes every element on its own line, indented two spaces for each parent above it, with Unix line breaks (LF). An element that holds only text, such as <title>Midnight Rain</title>, stays on one line. Minify drops the whitespace-only text between tags, which puts a typical document on one line. Text inside elements, attribute values, comments and CDATA sections are kept exactly as written, so a line break that is part of an element's text stays where it is.
While it builds the tree, the tool checks the structure: every opening tag needs a matching closing tag, tags must close in the order they were opened, and a document has a single root element. Problems are listed with their line numbers above the editors, and the XML is still formatted so you can see where the nesting goes wrong.
Assumptions and limits
- The check covers tags and nesting only. Attribute syntax, entity references such as &, namespaces and DTD or XSD schemas are not validated, so a document with no warnings can still be rejected by a strict parser.
- Leading and trailing spaces inside a text-only element are trimmed when beautifying, so <name> Ana </name> becomes <name>Ana</name>. An element with xml:space="preserve" is copied exactly as written in both modes.
- Elements that mix text and child tags, such as <p>Hello <b>world</b>!</p>, are not re-indented inside when beautifying, so the spaces and line breaks between their words don't change.
- Line breaks and extra spaces inside a tag, between attributes, are collapsed to single spaces. Attribute values themselves are never changed.
- The size shown is the UTF-8 size of the result in kilobytes (1 KB = 1,024 bytes), which is what the downloaded file takes on disk.
Worked examples
Beautify a one-line XML message
A 127-character note from an API arrives on a single line. Beautify splits it into 7 lines with nested elements indented; the result is 141 characters because of the added line breaks and spaces.
<?xml version="1.0"?><note priority="high"><to>Tove</to><from>Jani</from><br/><body>Don't forget me this weekend!</body></note> <?xml version="1.0"?> <note priority="high"> <to>Tove</to> <from>Jani</from> <br/> <body>Don't forget me this weekend!</body> </note>
Minify an RSS feed snippet
An indented feed of 180 characters becomes 144 after minifying: the line breaks and indentation between tags are removed, while 'Shop news' and the link keep their exact text.
<rss version="2.0"><channel><title>Shop news</title><item><title>Winter sale</title><link>https://example.com/sale</link></item></channel></rss>
Pretty-print a SOAP envelope
Namespaced tags such as soap:Envelope and m:GetPrice are indented like any others. This 213-character one-line request becomes 8 lines (238 characters) with four nested levels, showing where the body and the method call begin.
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<m:GetPrice xmlns:m="https://example.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>How to use the XML Formatter
- Paste your XML. Replace the sample catalogue in the Input Raw XML box with your document, feed or SOAP message.
- Pick Beautify XML or Minify XML. Switch modes in the toolbar; the Formatted Result box and the lines, characters and KB count update straight away. Fix any tag problems listed above the boxes.
- Copy or download. Press Copy XML, or Download to save the result as formatted.xml, or minified.xml in Minify mode.
Frequently asked questions
Does this XML formatter validate my XML?
Partly. It checks that every tag is closed, that tags close in the order they were opened and that there is one root element, and lists any problem with its line number. It doesn't check attributes, entities or a schema, so use a full validator when a system needs the document to pass a DTD or XSD.
What is the difference between beautify and minify?
Beautify is for people and minify is for machines. Beautify adds line breaks and two-space indentation so you can read the nesting; minify removes the whitespace between tags so the file is smaller to store or send. The elements, attributes and text are the same either way.
Can it re-indent XML that already has line breaks?
Yes. The indentation is rebuilt from the element tree, so XML with uneven or missing indentation, or with every tag on its own line at the left margin, comes out evenly indented with two spaces per level. Beautify XML on minified input gives the same result as on the original.
Can I format SVG, RSS, sitemap or SOAP XML?
Yes. They are all XML, so the same rules apply: each element on its own line and children indented under their parent. Namespace prefixes such as soap: or xmlns attributes are kept exactly as written, and a document whose root is <svg> downloads as an .svg file.
Does minifying XML change my data?
Not normally. It removes only whitespace-only text between tags; text inside elements, attribute values, comments and CDATA sections are untouched. That whitespace matters only in documents that treat it as data, and you can protect such an element by giving it xml:space="preserve".
Is my XML uploaded?
No. Beautifying, minifying and the tag check run in your browser, and the download file is created there too. Internal API responses and config files with credentials in them are never sent anywhere by this page.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.