XML Formatter
Format, validate, and minify XML documents. Powered by xml-formatter for robust processing.
Format, validate, and minify XML documents. Powered by xml-formatter.
How do I use XML Formatter?
Paste raw, SOAP, SVG, or minified XML into the editor, or click 'Sample' to load a starter XML document.
Select your indentation size (2 Spaces or 4 Spaces) or click 'Minify' to strip inter-element whitespace.
Verify XML well-formedness (matching start/end tags and attribute quoting), then copy the formatted XML output.
What features does XML Formatter offer?
Format, validate, and minify XML strings
Support for attributes, namespaces, CDATA, and comments
Clean indentation settings (2 spaces, 4 spaces)
100% client-side local browser execution — zero data uploads
W3C XML 1.0 Well-Formedness & Predefined Entity Escaping
Unlike lenient HTML parsers, W3C XML parsers abort immediately on unclosed tags, unquoted attributes, or unescaped reserved characters (`&`, `<`, `>`).
| Character / Construct | Raw Symbol | Required XML Escape | Allowed Unescaped Inside CDATA? |
|---|---|---|---|
| Ampersand | & | & | Yes (<![CDATA[ a & b ]]>) |
| Less-Than (Open Tag) | < | < | Yes (<![CDATA[ x < y ]]>) |
| Greater-Than | > | > | Yes (except ]]> terminator) |
| Double / Single Quote | " / ' | " / ' | Yes (Required in attributes) |
Frequently Asked Questions about XML Formatter
Why does my XML fail validation when a URL or text node contains an ampersand (`&`)?
In W3C XML 1.0, a bare `&` always begins an entity reference. Any literal ampersand in text or query parameters (`?a=1&b=2`) must be escaped as `&` (`?a=1&b=2`) or wrapped inside a `<![CDATA[ ... ]]>` section.
Does formatting or minifying XML alter `xml:space="preserve"` or CDATA blocks?
No. The XML tokenizer preserves `<![CDATA[...]]>` character data verbatim and only adjusts structural whitespace between element nodes.
Can I format SVG, RSS, Maven `pom.xml`, and Android `AndroidManifest.xml` files here?
Yes. SVG graphics, RSS/Atom feeds, SOAP envelopes, Maven `pom.xml`, and `.plist` files are standard XML documents and format cleanly with namespace prefixes (`xmlns:xsi`, `android:name`) preserved.
What is the difference between well-formed XML and valid XML?
Well-formed XML obeys W3C syntax rules (a single root element, properly nested closing tags, quoted attributes, and escaped entities). Valid XML additionally conforms to an external DTD or XSD schema.
Explore Related Developer Tools
Code Formatter
Format and beautify JavaScript, TypeScript, HTML, CSS, and Python code online with Prettier engine.
TypeScript & TSX Code Formatter
Format and beautify TypeScript (.ts) and React TSX (.tsx) code locally in your browser using the Prettier TypeScript AST parser.
Python PEP 8 Code Formatter
Format, indent, and beautify Python 3 scripts, functions, and classes to PEP 8 4-space indentation standards locally in your browser.
JavaScript Minifier
Minify and compress JavaScript files online with Terser engine. Mangle variable names and drop console logs.
.env File Editor
Visual editor for .env files — parse, validate, detect duplicate keys, mask secrets, and generate .env.example templates for Next.js, Django, Laravel, Rails, and more.
Regex Tester
Test regular expressions with live match highlighting, match details, and preset patterns.