Skip to content
TextArray
100% local

XML formatter

Pretty-print or minify XML with tag-nesting checks that name the offending tag.

Input
Output

XML formatter

Paste XML and this tool reformats it into cleanly indented markup — or strips it down to a single minified line. It handles the XML you actually meet in a working day: API responses, RSS and Atom feeds, sitemaps, SVG files, Maven and NuGet manifests, Android layouts and the config file a build tool just mangled onto one line.

Formatting puts every tag on its own line and indents children by two spaces, four spaces or a tab — your choice. "Collapse short elements" keeps an element with only text content, like a single SKU or a date, on one line, which keeps data-heavy documents compact and scannable; switch it off and every value moves to its own indented line. Comments, CDATA sections, processing instructions and the XML declaration all survive untouched, and whitespace-only text between tags is tidied away while real text content is kept. Minify does the reverse: it removes the whitespace between tags so the document is as small as it can get without changing its meaning.

While it works, the tool checks that tags nest correctly. A stray closing tag or an element that never closes produces a calm message naming the exact tag, so the fix takes seconds. Know the limits, though: this is a formatter, not a schema validator — it verifies nesting only, and attribute syntax passes through exactly as written, with no DTD or XSD checking.

Everything runs in your browser. No request is sent and nothing is logged, so feeds, exports and configs carrying internal data are safe to paste. The tally shows elements, depth and the size before and after.

FAQ

Is this an XML validator?
Only partly. It checks that tags open and close in the right order and names the tag when they do not. It does not validate against a DTD or XSD schema, and attribute syntax passes through as written — use a dedicated validator for schema conformance.
What does "Collapse short elements" do?
An element whose entire content is a single piece of text stays on one line instead of being split across three. That keeps data-heavy documents like feeds and exports much shorter. Turn it off to give every value its own indented line.
Are comments, CDATA and the XML declaration preserved?
Yes. Comments, CDATA sections, processing instructions and DOCTYPE declarations pass through byte-for-byte and are only re-indented. Whitespace-only text between tags is removed; real text content is kept.
What is the difference between formatting and minifying?
Formatting adds newlines and indentation so the structure is readable. Minifying removes the whitespace between tags so the document is as small as possible. Neither changes element names, attributes or text content.
Is my XML uploaded anywhere?
No. Parsing and formatting happen entirely in your browser and the XML never leaves your device — safe for feeds, exports and configuration files with internal data.