XML Formatter
Free XML formatter: pretty print or minify XML and check its syntax first. Runs in your browser; nothing is uploaded.
Raw XML
Stays in your browserResult
Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)
Next steps
Done here? Use the Send to… menu on the result to carry it on to XML/XSD Validator or Text Compare.
Online XML Formatter & Validator
Paste raw or minified XML to get a properly indented, readable version, or strip it down to the smallest possible size. Validate checks well-formedness — matching tags and valid structure — and reports the first error it finds, rather than silently producing garbage output on malformed input the way some tools do. The XML formatter pretty-prints or minifies a document and checks its syntax first. It helps developers inspect SOAP responses, XML feeds, and configuration files when compact markup hides the document structure.
How to format XML online
Paste raw or minified XML into the input box. Click Format to get a properly indented, readable version with each element on its own line — much easier to scan than a single unbroken line of tags. Click Minify to go the other way, stripping all whitespace between tags down to the smallest possible size. Click Validate to check well-formedness without reformatting anything.
What "well-formed" actually means
Well-formed XML means every opening tag has a matching closing tag, elements are properly nested (no overlapping tags), there's exactly one root element, and attribute values are quoted. This is a lower bar than validating against a specific schema (XSD or DTD) — the validator here confirms the XML's basic structure is sound, not that it conforms to a particular document type.
A note on error handling
The browser's native DOMParser never throws an exception on malformed XML — it silently returns a document containing an embedded error node instead. This tool explicitly checks for that error node and reports it clearly, rather than letting malformed input silently "succeed" and produce garbage output, which is a common pitfall when working with DOMParser directly.
Common use cases
- Making a minified SOAP or REST XML response readable for debugging
- Checking whether a hand-edited XML config file is still well-formed before deploying it
- Shrinking an XML payload before sending it over a bandwidth-constrained connection
Worked example
<root><user id="1"><name>Ada</name></user></root> formats to each tag on its own line, indented one level deeper per nesting level. Removing the closing </user> tag and clicking Validate reports a well-formedness error instead of silently accepting the mismatched structure.
Common mistakes and edge cases
- Well-formed isn’t the same as schema-valid — a document with all the right tags but the wrong element names or structure for your use case still passes Validate here, since this only checks XML syntax, not a specific XSD/DTD. Use the XML/XSD Validator tool for schema-level checks.
- An XML document needs exactly one root element — two sibling top-level elements (no shared wrapper) fails validation, which surprises anyone pasting an XML fragment rather than a complete document.