Format, Minify and Check XML
Paste XML and press Format to indent it readably, or Minify to strip it back down for transport or storage. Everything runs in your browser, so configuration files, API payloads, and exports never leave your machine.
Why did some elements stay on one line?
An element is kept on a single line when it holds exactly one simple child — text,
or a tag with no tags of its own — and the line still fits comfortably. So
<title>Report</title> and
<row><cell>1</cell></row> stay compact, while
anything with real structure inside it breaks out one child per line. The effect is that
deep documents stay readable without a wall of nearly-empty lines for leaf values.
The formatter also respects a line break you already put after an opening tag: if your
source has <root> on its own line, it stays that way even when it
would otherwise collapse.
What happens if my XML is invalid?
You get an error naming the tag, and nothing is reformatted. That is deliberate. XML,
unlike HTML, has no error recovery — a parser is required to reject a document with
a mismatched or unclosed tag rather than guess. Silently repairing it would hide exactly
the problem you opened a formatter to find, so a mismatched
</root> or a tag left open is reported instead.
What about CDATA, comments and the declaration?
CDATA sections are copied through untouched, markup and all — that is the whole
point of CDATA, and reindenting inside one would change the data. The XML declaration,
processing instructions such as <?xml-stylesheet?>, and a DOCTYPE each
get their own line at the top. Comments are kept on their own line, or removed entirely
with the Remove Comments option.
Is XML case-sensitive?
Yes, and this matters more than people expect coming from HTML. <Note>
and <note> are different elements, and a document mixing them is
invalid rather than merely untidy. Tag names, attribute names and namespace prefixes are
all passed through exactly as written — nothing is lowercased. Attribute values are
normalised to double quotes, with any embedded quote escaped as
".
What are the limits?
A very long opening tag with many attributes is kept on one line rather than being
wrapped across several, so an element with a dozen attributes can exceed a comfortable
line width. Everything else — nesting, mixed content, namespaces, CDATA, entities
— is handled. Entity references such as & are passed through
unchanged rather than being resolved, which is what you want when reformatting a
document you intend to keep as XML.
Related tools
For HTML, which has different rules and tolerates unclosed tags, use the HTML Formatter. For other structured formats see the JSON Formatter & Minifier and the JSON to YAML Converter.
Last reviewed: August 2026