About the XML Formatter
What is an XML formatter?
An XML formatter takes dense or single-line XML — a SOAP payload, an RSS feed, an SVG, a configuration file — and lays it out with one element per line and indentation that mirrors the document tree. This tool formats live as you type, keeps simple elements like <title>Clean Code</title> on a single tidy line, and leaves CDATA sections byte-for-byte untouched, since their whitespace is real data.
Every keystroke is also checked for well-formedness with the browser's native XML parser: a green badge means the document parses, a red one shows what broke. Switch the mode to Minify and the same document collapses to its smallest form — inter-element whitespace and comments removed, content preserved. No CDN libraries, no uploads: everything runs locally.
How to Use This Tool
- Add your XML. Paste it, open a file (
.xml,.svg,.rss…), or click Sample. - Check the badge. "Well-formed XML" in green, or the parser's complaint in red.
- Shape the output. Choose 2 spaces, 4 spaces, or tabs — or switch to Minify to compress the document.
- Take the result. Copy or download it; the size chips show what changed.
Common Use Cases
- Reading API payloads: Make SOAP and REST XML responses reviewable.
- Inspecting feeds and sitemaps: Expand RSS, Atom, and sitemap files into readable trees.
- Tidying SVG: Exported SVGs arrive as one enormous line; format them before editing by hand.
- Debugging config files: Maven, Android, and .NET configs are easier to fix when properly indented.
- Shrinking documents: Minify XML destined for transmission or embedding.
Need conversion instead? Try XML to JSON, reorder elements with the XML Sorter, or explore documents in the XML Viewer.
Frequently Asked Questions
What does "well-formed" mean, exactly?
Well-formed means the document obeys XML syntax: every tag closes, attributes are quoted, and there is a single root element. It is checked here with the browser’s native XML parser. Validity against a specific schema (XSD/DTD) is a separate, stricter concept this tool does not check.
Is CDATA content really untouched?
Yes. Anything inside is treated as opaque data — no re-indenting, no whitespace collapsing, in both beautify and minify modes. Comments are preserved when formatting and stripped when minifying.
Why are some elements kept on one line?
When an element contains only short text — like a title or a price — splitting it across three lines hurts readability. The formatter keeps such elements inline up to 80 characters and expands everything else.
Is removing whitespace between elements safe?
For data-oriented XML, yes: whitespace between elements is insignificant. Inside text content and CDATA it can be meaningful, which is why the minifier only trims around element boundaries and never inside CDATA.
Can I format SVG files with it?
Yes — SVG is XML, and the file picker accepts .svg directly. For deeper SVG-specific cleanup, the SVG Optimizer is the dedicated tool.
Is my XML private?
Yes. Parsing, formatting, and minifying all run locally in your browser with no CDN dependencies and no uploads, and the tool works offline once loaded.