Prettify XML
Format and indent XML with customizable indentation. Makes XML readable and well-structured. 100% client-side.
Paste minified or badly indented XML and get it back with clean, consistent formatting — 2 spaces, 4 spaces, or tabs. Syntax errors show up right away, so you catch broken tags before anything else touches the file. And everything runs in your browser. Nothing gets uploaded.
How It Works
The browser's built-in DOMParser reads your XML and builds a tree of every element, attribute, and text node. Then a recursive formatter walks the tree, adding your chosen indentation at each depth level. CDATA blocks and comments stay untouched — only whitespace changes.
Examples
Minified API response
A SOAP service returned everything on a single line. You need to read the actual data.
<users><user id="1"><name>Alice</name><role>admin</role></user><user id="2"><name>Bob</name><role>editor</role></user></users>
<users>
<user id="1">
<name>Alice</name>
<role>admin</role>
</user>
<user id="2">
<name>Bob</name>
<role>editor</role>
</user>
</users>
Maven pom.xml with inconsistent spacing
Half the file uses tabs, the other half uses 3 spaces. The prettifier normalizes it all to your preferred indent style.
<project>
<groupId>com.app</groupId>
<artifactId>core</artifactId>
<version>2.1.0</version>
</project>
<project>
<groupId>com.app</groupId>
<artifactId>core</artifactId>
<version>2.1.0</version>
</project>
Nested SVG markup
Exported SVG from a design tool — deeply nested groups and paths all jammed together.
<svg><g id="layer1"><rect width="100" height="50"/><circle cx="25" cy="25" r="10"/></g></svg>
<svg>
<g id="layer1">
<rect width="100" height="50"/>
<circle cx="25" cy="25" r="10"/>
</g>
</svg>
Who Uses This
Debugging SOAP responses and XML-based API payloads that arrive as a single wall of text.
Cleaning up Maven pom.xml files, Tomcat configs, or CI pipeline definitions before committing.
Reading exported SVG code to hand-edit paths, colors, or viewBox dimensions.
Making sense of XML data feeds from government or financial APIs before converting to CSV.
Common Mistakes
HTML has self-closing tags like <br> and <img> that aren’t valid XML. The parser will throw an error. If you’re working with HTML, use the HTML Beautifier instead.
Not an error here, but some systems need <?xml version="1.0"?> at the top. The tool preserves it if it’s there — it won’t add one automatically.
A bare & in XML is illegal. You’ll see a parse error if your data has something like AT&T instead of AT&T. Fix the source data first, then prettify.
Technical Details
- Processing: 100% client-side — uses the browser’s native DOMParser
- Browser Support: Chrome, Firefox, Safari, Edge
- Indent Options: 2 spaces, 4 spaces, or tab characters
- Preserves: CDATA sections, comments, processing instructions
- Max Size: Limited only by your browser’s available memory
Frequently Asked Questions
What does XML prettifying actually do?
It takes minified or badly indented XML and reformats it with consistent line breaks and indentation. Each nested element gets indented one level deeper than its parent. The data itself doesn’t change — only the whitespace around tags.
Will this tool fix broken XML?
No. It catches errors and tells you where they are, but it won’t auto-repair missing closing tags or unescaped characters. You’ll need to fix those yourself, then run the prettifier again. Think of it as a formatter, not a fixer.
Is there a file size limit?
There’s no hard limit — it depends on your browser and how much memory your device has. Files under 10 MB format almost instantly. Larger files work too, but they might take a few seconds.
Does it keep my CDATA and comments?
Yes. CDATA sections pass through untouched because their content is meant to be raw text. Comments get preserved and indented to match the nesting level where they appear.
Is my XML data safe? Does it get uploaded?
Your data stays on your device. The formatting runs entirely in JavaScript inside your browser — nothing gets sent to any server. Close the tab and it’s gone.