XML Formatter

Beautify, minify and validate XML in your browser - with the exact line and column of any error. Nothing leaves your machine.

Beautify, minify and validate XML

XML is still the backbone of countless configs, feeds and enterprise APIs, but a real document often arrives as one unbroken line or with wildly inconsistent indentation. Paste it above and pick Beautify for clean, indented output you can actually read, or Minify to strip every optional space and newline for the smallest possible payload. Validate just checks the document is well-formed and tells you where it breaks if not.

How the beautifier works

Rather than guessing with regular expressions, this tool parses your XML into a real document tree with the browser own parser, then walks that tree to re-print it. That means attributes keep their order, an element with a single short text child stays on one line (so <title>XML</title> is not needlessly split), and structural nodes are preserved: CDATA is copied verbatim, comments sit on their own lines, and the XML declaration is kept at the top. Because the output is generated from the parsed tree, malformed input is caught before anything is printed.

Reading a validation error

When the parser hits a problem it reports the line and column of the first error and a short description - the most common being a start tag with no matching end tag, tags that overlap instead of nesting, an unquoted attribute value, or more than one root element. The caret preview points straight at the offending spot so you can fix it without hunting.

Working with other formats? Convert a document with the XML to JSON converter, tidy data with the JSON formatter, or turn config into YAML with the JSON to YAML converter.

Frequently asked questions

What does an XML formatter do?
It re-prints XML with consistent indentation and line breaks so nested elements are easy to read, or strips every optional space and newline to minify it. It also checks that the document is well-formed and points to the line and column of any error.
What counts as well-formed XML?
Every opening tag must have a matching closing tag (or be self-closed), tags must nest correctly, attribute values must be quoted, and there must be exactly one root element. This tool parses your input with the browser XML engine and reports the first place these rules are broken.
Does formatting change my data?
No. Beautifying and minifying only add or remove whitespace between tags. Element names, attributes, text content, CDATA sections and comments are all preserved exactly, so beautify and minify are lossless opposites of each other.
Are CDATA and comments kept?
Yes. CDATA blocks are copied through verbatim, including any characters that would otherwise need escaping, and XML comments are preserved on their own lines. Processing instructions like the XML declaration are kept too.
Is my XML uploaded anywhere?
No. All parsing, formatting and validation happens in your browser with JavaScript. Nothing you paste is sent to a server, so it is safe to use with private configs and API payloads.