How to use XML Formatter
What it does & when you need it
XML arrives in all shapes: a minified SOAP response on one line, a hand-edited
pom.xml, an SVG exported without a single line break, an RSS feed you need to
read. This tool re-indents that markup into a clean, nested tree so you can follow
the structure — or, in reverse, collapses a tidy document down to the smallest
single-line form for transport. It is a lightweight formatter written from
scratch, so it runs instantly in your browser and never uploads what you paste.
How to use
- Paste your XML into the left buffer, or press Sample to load an example catalog with a declaration, comment, attributes, and a self-closing tag.
- Leave Minify off to pretty-print. Pick a 2 or 4 space indent from the dropdown.
- Tick Minify to strip the whitespace between tags and produce one compact line; the status bar reports how many bytes you saved.
- Press Copy result or
Ctrl/Cmd+Enterto copy the output.
Things worth knowing
It preserves what matters. Attributes keep their exact quoting, the <?xml?>
declaration stays on top, and comments, <![CDATA[ ]]> sections, and self-closing
tags like <br/> pass through untouched. A > that appears inside a quoted
attribute value will not fool the tokenizer into ending the tag early.
Short text stays inline. An element that wraps a single short text node, such
as a title, is kept on one line as <title>XML Basics</title> rather than being
exploded across three, which keeps the output compact and readable.
It catches broken nesting. The formatter tracks open tags on a stack, so a
mismatched pair like <a></b> or an element you forgot to close reports an error
that names the tag, instead of silently emitting garbage.
It is a formatter, not a schema validator. It will not check your document against a DTD or XSD, resolve entities, or confirm namespace prefixes are declared. For structured JSON instead, see the JSON formatter; for HTML markup, the HTML formatter understands void elements and inline whitespace rules that XML does not share.