What XML formatting does
XML is a text format built from nested elements, each wrapped in an opening tag and a closing tag, with optional attributes inside the opening tag. Machines do not care how that text is laid out, so XML often travels as one long line with no spaces between tags. That is efficient to send but very hard for a person to read.
Formatting, often called pretty-printing, puts each tag on its own line and indents child elements under their parent. The content of the document does not change; only the whitespace between tags does. After formatting you can see the tree structure at a glance: which element contains which, where an element closes, and where something is missing.
When you need a formatted XML view
Developers run into one-line XML all the time: an API response, a sitemap, an RSS feed, a configuration export, an Office document part, or a SOAP message copied from a log. Reading any of these without indentation means counting angle brackets by eye.
Formatting is also a quick way to spot structural mistakes. If a closing tag does not line up under its opening tag, or the indentation drifts further right with every line, something is probably unbalanced. Clean indentation also makes diffs in version control far easier to review, since each element sits on its own line. If you want to compare two versions side by side, the Text Diff Checker works well on formatted output.
How to format XML with this tool
- Paste your XML into the box labeled XML. It starts with a small sample so you can see how it behaves.
- The tool first checks the text with the browser's built-in XML parser. If the text is not well-formed, you see the message "This doesn't look like valid XML." instead of a result.
- If it parses, the Formatted box fills in automatically, using two spaces per level of nesting. There is no button to press and no indent option.
- Click Copy to put the formatted text on your clipboard. There is no download button.
Everything runs in your browser. The XML is not sent anywhere.
Limits and things to watch for
This is a lightweight tag-based indenter, not a full XML serializer. Text inside an element is placed on its own line, so a short element like an item with the word Hello inside is shown as three lines (opening tag, text, closing tag) rather than one. That is fine for reading, but keep it in mind if whitespace inside a text value matters to you, since leading and trailing spaces in text are trimmed.
Comments, DOCTYPE declarations and CDATA sections are not given special handling. A comment or DOCTYPE line is treated like an ordinary opening tag, so the lines after it may be indented one level too deep. Processing instructions such as the XML declaration at the top are handled correctly. For documents that depend on those constructs, double-check the result before using it.
The tool formats only; it does not validate against a schema and does not fix broken markup. If you work with JSON in the same project, the JSON Formatter does the equivalent job for that format.