XML Formatter
Paste raw or minified XML and instantly beautify it, check that it is well-formed with the exact error line, or minify it. Pick your indentation, copy the result with one tap, and move on — no account, no upload, no waiting.
What is the XML Formatter?
The XML Formatter is a free online tool that takes raw, messy, or minified XML and turns it into clean, properly indented, readable text. It also checks your input on the fly: if the document is not well-formed, it tells you the exact line and column of the first problem instead of just saying "invalid." In one page you can beautify XML for debugging, minify it for production, or simply confirm a payload is well-formed before you ship it.
Well-formedness, explained
XML has strict rules. A document is well-formed when it has exactly one root element, every tag is closed and correctly nested, attribute values are quoted, and special characters such as ampersands and angle brackets are escaped. Unlike HTML, a browser will not quietly fix sloppy XML — a single unclosed tag breaks the whole document. This tool uses the browser's native parser, so a valid result here means your XML will parse anywhere a standards-compliant XML reader is used.
Beautify vs. minify
Beautifying expands the document with line breaks and indentation so the nesting is obvious at a glance — ideal while reading or debugging. Minifying strips the whitespace between tags to make the file as small as possible — ideal for storage, transfer, or embedding in a string. The tool shows the byte size before and after minifying so you can see exactly how much you saved.
How to use it
- Paste or type your XML into the input box — for example a SOAP response, an RSS feed, a sitemap, or an SVG file.
- The tool checks it as you type. If it is well-formed, the result appears immediately; if not, you get a message pointing to the offending line.
- Click Beautify to indent it, or Minify to compress it.
- Pick your indentation — 2 spaces, 4 spaces, or tabs — to match your project.
- Click Copy to grab the result. Done — no account, no upload, no waiting.
The method behind it
The tool parses your input with the browser's native DOMParser into a real
document tree, then walks that tree and re-serializes it with consistent indentation. Because
parsing relies on the same XML engine the browser uses everywhere, well-formedness checking is
exact rather than a guess: if the parser reports an error, the tool reads the line and column
and shows them to you. Beautifying joins the serialized nodes with newlines and indentation;
minifying joins them with nothing, collapsing the document to its smallest equivalent form
while preserving any XML declaration at the top.
Examples
Beautify a one-line element
Input: <note><to>Ada</to><from>Grace</from></note>
Output:
<note>
<to>Ada</to>
<from>Grace</from>
</note> Minify a config for production
Input: a pretty-printed config with lots of indentation. Output: a single compact line with the whitespace between tags removed, ready to drop into an environment variable.
Catch a tag mismatch
Input: <a><b></a>. Output: an error reporting an opening and ending tag
mismatch at the exact line and column, so you know precisely what to fix.
Common use cases
- API and SOAP debugging — read a raw response without squinting at one long line.
- Feeds and sitemaps — clean up RSS or Atom feeds and
sitemap.xmlbefore publishing. - SVG and config files — beautify a hand-edited SVG or app config to spot the structure.
- Validating payloads — confirm a request body is well-formed before sending it.
- Shrinking for transfer — minify large XML to cut payload size for storage or network calls.
Why use this one
Most options make you jump between a separate formatter, validator, and minifier. This tool does all three in one place, with one-click copy and indentation control. More importantly, everything runs entirely in your browser, so your XML never touches a server — which matters because real documents often carry tokens, credentials, or customer data. It is fast (no round-trip to a server), works on mobile, and needs no signup. Working with other formats too? Use the JSON Formatter, the HTML Formatter, or compare two versions with the Text Diff Checker.
Frequently asked questions
Is my XML safe — is anything uploaded to a server?
No. All formatting, validation, and minifying happen entirely inside your browser using the native DOMParser. Your XML is never sent to, stored on, or seen by any server, so it is safe to paste payloads that contain tokens, keys, or private data.
What is the difference between beautifying and minifying XML?
Beautifying adds indentation and line breaks so the structure is easy to read while debugging. Minifying strips the whitespace between tags to make the document as small as possible for storage or transfer. This tool does both with one click and shows the byte size saved.
What does 'well-formed' mean and why does my XML show as invalid?
Well-formed XML has exactly one root element, every tag closed and correctly nested, quoted attribute values, and escaped special characters. Common errors are an unclosed or mismatched tag, more than one root element, a stray & that is not written as &, or a missing quote. The validator points to the exact line and column of the first problem so you can fix it fast.
Can I change the indentation size?
Yes. You can choose 2 spaces, 4 spaces, or tab indentation when beautifying, so the output matches your project's or team's style guide.
Does it work on mobile and with files like SVG, RSS, or SOAP?
Yes. The tool is fully responsive and works in any modern mobile browser. Because it relies on a standard XML parser, it handles any well-formed XML, including SVG graphics, RSS/Atom feeds, sitemaps, SOAP envelopes, and configuration files.