Beautify XML online with Calzyra's free XML Beautifier. Paste messy or minified XML and get back readable, properly indented markup you can copy into your project.
Formatted XML will appear here
Paste XML in the input panel and it formats automatically
Load sample data to get started
What this tool can do
Indent by Nesting
Two spaces per level, matching the XML Formatter
Beautifies As You Type
The output refreshes while you edit; Ctrl+Enter forces a re-run
Attributes Preserved
Names, values, quoting and order stay exactly as written
Comments & CDATA Kept
Comments, CDATA sections and the declaration pass through
Text Spacing Intact
Spaces inside text nodes are never rewritten
Real XML Parsing
Malformed XML reports the error with line and column
Copy & Download
Copy the beautified XML or save it as output.xml
Clear Both Panels
Reset the input and the output in a single step
Methodology and approach
The beautifier parses the document and writes it back out with two-space indentation and a line per element, leaving mixed content inline so its text is never rewrapped - the same engine the XML Formatter runs.
XML that arrives from an API response, a build step or a copied log is often written on one very long line, or indented by whichever tool last touched it. An XML beautifier rewrites that document with consistent indentation and line breaks so the nesting is visible again: which elements hold which, where one record ends and the next begins, and which attributes ride on which tag.
This tool parses the document with a real character-by-character XML parser rather than a pattern that only inserts a line break between two angle brackets, so the structure it prints is the structure the document actually has. It runs the same beautification engine the XML Formatter page uses - the two names lead to one implementation.
Paste your XML into the input panel on the left - a sample document is already loaded. It is parsed and beautified automatically as you type, and Ctrl+Enter forces a re-run at any time. The beautified document appears in the output panel on the right, with a status line reporting that the document is valid and how many lines the result spans.
Content that does not parse is reported rather than guessed at: the output panel clears and the message above it shows the parser's error with its line and column, while your input is left exactly as it was. An empty input simply asks for XML. Fix the problem in place and the beautified output returns on its own.
When the result looks right, Copy puts the beautified document on the clipboard - indentation included - and Download saves it as output.xml. Clear empties both panels, Upload reads a file from your disk, and everything runs in your browser; nothing is uploaded.
<?xml version="1.0" encoding="UTF-8"?><catalog><book id="1"><title>XML in Practice</title><price>29.99</price></book><book id="2"><title>Learning XML</title><price>39.95</price></book></catalog><?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="1">
<title>XML in Practice</title>
<price>29.99</price>
</book>
<book id="2">
<title>Learning XML</title>
<price>39.95</price>
</book>
</catalog>Every nesting level adds two spaces, an element with element children gets one child per line, and opening and closing tags line up with each other. Indentation-only whitespace that sat between those children in the source is replaced by the indentation this tool writes, so the same input always produces the same output and a diff of two versions shows real changes rather than layout noise.
Two situations deliberately keep their original layout. An element that mixes text or CDATA with child elements is written on one line, because inserting a line break into that text would change the spacing a consumer reads - "hello world" keeps every space. And empty elements keep the form the document gave them: a self-closing tag stays self-closing and a paired empty element stays paired, so nothing you pasted is silently reshaped. Attributes, comments, CDATA sections and the XML declaration are copied through in the order and quoting the document used.
<note><greeting>hello world</greeting><message>Ship it on <strong>Tuesday</strong></message></note><note>
<greeting>hello world</greeting>
<message>Ship it on <strong>Tuesday</strong></message>
</note>The two answer different questions. Beautifying asks how a document can be laid out so a person can read it; validating asks whether the document is well-formed at all - matching and properly nested tags, exactly one root element, quoted attributes, and only entity references the document declares. This tool parses the document before it writes anything, so malformed XML is always reported with its position instead of being printed as re-indented output - but a document that beautifies cleanly is not thereby valid, and no schema is checked here.
In practice the two work as a pair. Validate first to learn whether the document parses and where it breaks, then beautify to read the structure around the part you need to change. The XML Validator beside this tool parses with the same parser, so the errors it reports are the errors this beautifier refuses to format.
Reading an XML API response that arrives as one long line, when the shape of the payload needs to be understood rather than guessed at. Editing a configuration file - a build descriptor, a server config, a deployment manifest - before changing it, so the nesting is clear before the first edit is made. Reviewing an export or a feed by eye to see which record carries which field, and preparing a document to share in a pull request or a support ticket, where unreadable source slows everyone down.
It is the wrong tool when the goal is a smaller document - that is minification, and the XML Minifier beside this tool removes exactly the whitespace a beautifier adds - or when the document must be checked against a schema, which belongs to an XSD-aware processor rather than a beautifier. For making XML readable, this is the shortest path.
Common questions about this tool