XML Formatter & Validator
Format, beautify, minify and validate XML instantly — with the exact line and column of any error.
About XML Formatter & Validator
What is XML?
XML (Extensible Markup Language) is a text format for describing structured data using nested tags. It predates JSON and still runs a huge amount of the software world: RSS and Atom feeds, sitemaps, SOAP web services, SVG graphics, Office and OpenDocument files, Maven and Spring configuration, Android layouts, .NET config files, and almost every enterprise data-exchange format you will meet in banking, healthcare and logistics.
Why do you need an XML formatter?
XML produced by machines almost never arrives readable. An API response or an exported config file typically comes as one unbroken line thousands of characters long, because whitespace costs bandwidth. Beautifying it puts every element on its own line with indentation that mirrors the nesting, which is usually all it takes to see the structure — and the bug. The Minify button does the reverse when you need to shrink a payload before sending it, and the validator points at the exact character that breaks the document instead of just refusing it.
How to use this tool:
1. Paste your XML into the "Input XML" box, or use "Upload file" to load an .xml, .xsd, .svg or config file from your computer.
2. Choose your indentation — 2 spaces, 4 spaces, or a tab, to match your project's style.
3. Click "Format XML" to beautify, "Minify XML" to strip the whitespace back out, or "Validate" to check well-formedness without changing anything.
4. If the document is broken, the right pane shows the message, the offending line, and a caret under the exact column — start there rather than re-reading the whole file.
5. Use "Copy" or "Download" in the toolbar to take the result away as text or as a formatted.xml file.
What "well-formed" actually means
XML is far stricter than HTML, and virtually every parse failure comes down to one of six things. Unclosed tags — every <item> needs its </item>, and empty elements must be written <item/>. Case and nesting mismatches — tag names are case-sensitive, so <Item> is not closed by </item>, and tags must close in the order they were opened (<a><b></a></b> is invalid). Unescaped characters — a bare & or < in text must be written & and <, which is why "Tom & Jerry" breaks a parser and is the single most common failure in hand-edited XML. More than one root element — everything must sit inside exactly one outermost element. Unquoted attribute values — HTML tolerates width=100, XML never does; it has to be width="100". Duplicate attributes — the same attribute name cannot appear twice on one element. Note that well-formed is not the same as valid: this tool checks well-formedness (the syntax rules above), not conformance to a DTD or XSD schema.
Privacy & Security Guarantee
Every step runs inside your browser using client-side JavaScript — there is no server-side processing and no upload. That matters more for XML than for most formats, because the XML people need to debug tends to be production configuration, SOAP envelopes with credentials in the header, or customer records in an enterprise export. None of it leaves your machine. Working with JSON instead? Try the JSON Formatter & Validator, or move data between the two formats with XML to JSON and JSON to XML.
Frequently Asked Questions
Is my XML data secure?
Yes. All parsing, formatting, minifying and validating happens entirely inside your browser using client-side JavaScript. Your XML is never uploaded, logged or transmitted anywhere, so it is safe to paste production configuration files, SOAP envelopes and customer data exports.
Why am I getting a 'not well-formed' error?
In practice it is almost always one of six causes: an unclosed tag, a case or nesting mismatch (<Item> closed by </item>, or tags closed out of order), an unescaped & or < in text content, more than one root element, an unquoted attribute value such as width=100, or the same attribute repeated twice on one element. This tool reports the exact line and column plus a caret under the offending character, so start reading there rather than scanning the whole file.
What is the difference between well-formed and valid XML?
Well-formed means the document obeys XML's syntax rules — tags close correctly, there is a single root, special characters are escaped. Valid means it also conforms to a schema (a DTD or XSD) that dictates which elements are allowed, in what order, and with which data types. This tool checks well-formedness only; a document can be perfectly well-formed and still fail schema validation.
Does formatting change my data?
No. Only whitespace between elements is rewritten. Text content is preserved exactly, entity references such as & are passed through untouched rather than decoded, and CDATA sections, comments, processing instructions and the DOCTYPE declaration are all kept. Elements containing mixed content — text sitting alongside child elements, like <p>Hello <b>world</b> now</p> — are deliberately left on one line, because in XML that inner whitespace can be significant and reflowing it would alter your data.
Can this tool handle large XML files?
Yes. Because the work happens on your own machine there is no upload limit or server timeout — the only ceiling is your browser's available memory. Files in the low tens of megabytes are generally fine; extremely large documents may make the browser tab pause while it renders the result.
What is the difference between minifying XML and gzipping it?
Minifying removes the indentation and line breaks between elements, shrinking the document itself, and the result is still readable XML that any parser accepts. Gzip compresses the bytes in transit and has to be decompressed before use. They stack: gzip already handles repetitive whitespace efficiently, so minifying a gzipped response saves relatively little, but minifying is still worth it for XML stored in databases, embedded in other payloads, or sent where compression is unavailable.