An XML formatter takes raw, single-line or messy XML and pretty-prints it with clean, consistent indentation โ or minifies it back down โ while checking that the document is well-formed and pointing to the exact line and column of any error. The tool above does all of this in your browser: paste XML on the left, get formatted output on the right, then copy or download the result. Nothing you paste is transmitted anywhere.
What is XML?
XML (eXtensible Markup Language) is a text-based format for storing and exchanging structured data using nested tags. Unlike HTML, which has a fixed set of tags for describing web pages, XML lets you invent your own element names to model whatever your data needs. It powers configuration files, document formats such as DOCX and SVG, RSS and Atom feeds, SOAP web services, sitemaps, and countless enterprise data exchanges.
A small XML document looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<price>44.95</price>
</book>
What does an XML formatter do?
XML from an API, a feed, or an export often arrives collapsed onto a single line with no indentation. That is efficient to transmit but very hard to read. A formatter parses the markup into a document tree, confirms it is well-formed, then re-serialises it with one element per line and consistent indentation so the nesting is obvious at a glance. Minifying does the reverse: it strips the whitespace between tags to make the payload as small as possible, without altering any text content or attribute values.
This tool uses the browser’s own DOMParser to parse and check the document, then walks the resulting tree to rebuild the indented output. Because parsing must succeed before anything can be pretty-printed, formatting doubles as a well-formedness check.
Well-formed versus valid
These two terms are often confused, and they mean different things:
| Well-formed | Valid |
|---|---|
| Follows XML syntax rules: matched, properly nested tags, quoted attributes, a single root element. | Also conforms to a schema (DTD or XML Schema) that defines which elements and attributes are allowed. |
| Checked by this tool, entirely in your browser. | Requires the schema, which this tool does not process. |
Every valid document is well-formed, but a well-formed document is not necessarily valid against a particular schema. This formatter checks well-formedness โ the foundation every XML parser requires first.
Common XML errors and how to fix them
- Tag mismatch โ a closing tag does not match the element it is meant to close, for example
<b>...</a>. Make the names match and check the nesting order. - Unclosed tag โ an element is opened but never closed, which triggers a “premature end of data” error. Add the missing closing tag or use a self-closing form such as
<br/>. - Multiple root elements โ a well-formed document must have exactly one top-level element. Wrap siblings in a single container.
- Unquoted attribute values โ every attribute value must be inside single or double quotes.
- Unescaped special characters โ a raw
&,<, or>inside text breaks parsing. Use the entities&,<, and>, or wrap the content in aCDATAsection.
When parsing fails, the status line reports the line and column so you can go straight to the problem instead of scanning the whole document.
Common use cases
- Reading an API or SOAP response that arrived minified on one line.
- Inspecting an RSS or Atom feed, a sitemap, or an SVG file.
- Validating a config file is well-formed before committing or deploying it.
- Minifying XML to reduce payload size for storage or transport.
- Diffing two documents by formatting both with the same indentation first.
Is it safe to paste sensitive XML here?
Yes โ this tool never sends your input anywhere. Parsing, validation, and re-serialisation all happen with the browser’s native XML parser, on your device. There is no server round-trip, no logging, and no third-party analytics on this page. As with any online tool, treat the most sensitive payloads with healthy caution: our source is open so you can verify the behaviour, and once the page has loaded you can disconnect from the network and it will still work.