Skip to main content

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 browser

Result

Formatted, minified, or validated XML will appear here.

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.

Frequently asked questions

What does "Validate" actually check?
It checks well-formedness — that every tag is properly opened, closed, and nested, and that the document follows valid XML syntax overall. It does not validate against a specific schema (XSD/DTD); it only confirms the XML itself is structurally correct.
What happens if I try to format invalid XML?
The tool reports an error instead of producing output. Some tools silently produce garbage when given malformed XML — this one explicitly detects a parse failure and tells you, rather than guessing at a "best effort" result.
Is my XML data uploaded anywhere?
No — parsing, formatting, and validation all happen locally in your browser using the native DOMParser API. Nothing you paste is ever sent to a server.
When should I minify XML instead of formatting it?
Minify when you need the smallest possible payload for transmission or storage — for example, embedding XML in a request body. Format (pretty-print) when you need to read or debug the structure by eye.
How do I check XML syntax online?
Press Validate before you format. It reports unclosed tags, wrong nesting and attributes without quotes, with the line where the parser stopped. Fixing the first error often clears the ones after it, so work from the top.

Related tools

More Formatters & Parsers

View all Formatters & Parsers tools →