How to Format & Validate XML
XML that arrives from an API or a legacy system often comes as one enormous line, which makes it nearly impossible to see the structure or spot the tag that's out of place. This tool fixes both problems at once. Paste your XML and it's tokenised and re-indented so every element sits at its correct nesting level, with declarations, comments and self-closing tags all handled properly rather than throwing off the indentation. At the same time, a stack-based check walks every tag to confirm the document is well-formed — and when it isn't, it names the specific problem: which tag was expected, which was found, or which one was left unclosed. That's far more useful than a generic parse failure. You also get a quick structural readout, the element count and maximum nesting depth, which is a fast way to sanity-check that a document is the shape you expected. Switch to minify when you need the smallest possible payload for transport. Everything runs in your browser, so confidential documents never leave your device.
Paste your XML
Drop in minified or messy XML; it's parsed locally.
Pick indentation
Two spaces, four spaces, tabs — or minify instead.
Copy or download
Grab the clean result or save it as an .xml file.
Well-Formed vs Valid
Well-formed
The document follows XML's syntax rules: every element is closed, tags nest correctly, and special characters are escaped. That's what this tool checks, and it's the baseline any XML parser requires.
Valid
A stronger claim: the document also conforms to a schema such as an XSD or DTD, which dictates which elements may appear where. Schema validation needs the schema itself, so it's a separate step.
Common Use Cases
Read an API response
Beautify a one-line SOAP or REST XML response to see its structure.
Debug a broken document
Find the exact tag that's mismatched or left unclosed.
Clean config files
Format XML configuration consistently before committing it.
Shrink payloads
Minify XML before sending it over the network.
RSS & sitemaps
Check feed and sitemap XML is well-formed before publishing.
Legacy integrations
Inspect XML from older enterprise systems quickly.
Documentation
Present tidy XML examples in docs and tutorials.
Pre-commit checks
Confirm XML parses before it reaches production.
Tips & Best Practices
Escape special characters
Raw &, < and > inside text break XML. Use &, < and > instead.
Close every element
Unlike HTML, XML has no optional closing tags — use </tag> or a self-closing <tag/>.
Remember XML is case-sensitive
<Item> and <item> are different elements, and mixing them causes mismatch errors.
Keep the declaration
An XML declaration with the encoding avoids ambiguity for parsers reading your file.
Minify for transport only
Ship minified XML but keep a beautified copy in version control for readable diffs.
Validate against a schema too
Well-formed only means the syntax is right; use an XSD to check the content is correct.
Troubleshooting
It says a tag is mismatched
The message names both the expected and the found tag. Check for a typo or wrong nesting order at that point.
It says a tag is unclosed
An element was opened but never closed. Add the closing tag, or make it self-closing if it should be empty.
My ampersands cause errors
A bare & is invalid in XML. Replace it with & — likewise < and > for angle brackets.
Text moved onto the tag line
That's intentional. Short text content stays inline with its element, which keeps the output compact and readable.
Frequently Asked Questions
How do I format XML for free?
Paste your XML above and it's beautified instantly. Choose your indentation or minify, then copy or download — free, no signup.
Does it validate my XML?
Yes. It checks well-formedness live and names the exact tag that's mismatched or unclosed when something is wrong.
Can it minify XML?
Yes. Choose Minify to strip the whitespace between tags for the smallest transportable output.
What indentation can I use?
Two spaces, four spaces or tabs, so the output matches your project's conventions.
Does it handle self-closing tags?
Yes. Empty elements like <tag/> are handled correctly and don't affect the indentation.
Does it keep the XML declaration?
Yes. Declarations and comments are preserved and placed at the correct level.
What's the difference between well-formed and valid?
Well-formed means the syntax is correct; valid means it also conforms to a schema such as an XSD. This tool checks well-formedness.
Can it check against an XSD?
No. Schema validation needs the schema file itself, which is a separate step from formatting.
Why does it report an error on my ampersand?
A bare & is invalid in XML. Escape it as & and the document will parse.
Is XML case-sensitive?
Yes. <Item> and <item> are different elements, which is a common source of mismatch errors.
Is my data sent to a server?
No. Everything happens inside your browser, so your data never leaves your device.
Can I download the result?
Yes. Save the output as an .xml file, or copy it to your clipboard.
How large a file can it handle?
It comfortably formats large XML documents, all within your browser.
What do the element count and depth mean?
The number of opening elements and the deepest level of nesting — a quick way to sanity-check a document's shape.
Can I convert XML to other formats?
Yes — try our XML to JSON and XML to CSV converters.
Does it preserve attributes?
Yes. Attributes are kept exactly as written on their elements.
Does it work on phones?
Yes, in any modern browser on Windows, Mac, Android or iPhone with nothing to install.
Is this tool really free?
Completely free, forever — no account, no ads and no premium wall.
100% free · No signup · Processed in your browser · Data never sent
Last updated: August 2026 · FlipMyFormat XML Formatter & Validator
Written and maintained by the FlipMyFormat team · Runs entirely in your browser