🛠️Dev Toolbox

📄 XML Formatter

Format, validate, and beautify XML documents with customizable indentation options.

XML has a reputation problem. People associate it with SOAP services that clock in at 200 lines, or Maven POM files from 2006. But XML is still everywhere: SVG files, RSS feeds, Android layouts, Microsoft Office documents. When you need to read one, you need to format it first — raw XML is frequently delivered as a single 8 KB line and good luck reading that.

Paste XML, get indented XML. Pick 2 or 4 spaces. The formatter walks the element tree and produces properly nested output, attributes aligned, line breaks where they should be. Crucially, it preserves CDATA sections unchanged — no one wants their ]]> delimiters mangled by an over-eager formatter.

Validation matters here because the penalty for malformed XML is total failure. JSON might tolerate a trailing comma or two. XML terminates at the first unclosed tag, invalid encoding declaration, or namespace prefix that's never been declared. The parser catches these before you ship the file. Error messages include line and column numbers.

The minifier does the opposite — collapses to a single line, no whitespace, no comments. Useful when you're serializing for network transport or embedding in a config file where byte size matters. For SVG files specifically, the difference between formatted and minified can be significant: a complex Illustrator-exported SVG might be 40% smaller minified.

The "does the formatter change my data?" question comes up constantly. The answer: it changes whitespace only. By the XML InfoSet spec, two documents with different whitespace in element content are different, but in practice almost every consumer treats whitespace between elements as insignificant. If whitespace IS significant in your document (say, you're representing poetry or a formatted letter), preserve-whitespace mode skips the indentation pass entirely.

Namespaces are the perennial pain point. The tool preserves existing declarations, doesn't invent prefixes, doesn't rename things. It won't fix your broken namespace references either — if you're using foo:bar without declaring xmlns:foo, the formatter will preserve your error exactly as it found it. Fix namespaces first, then format.

For SVG cleanup specifically: minify after you've removed editor metadata. Most design tools (Illustrator, Inkscape, Figma) export comments, editor attributes, and unused namespaces. Strip those in your editor of choice, then paste here for final minification.

More Developer Tools

Explore our complete collection of 60+ free developer tools at dev.aisoosoo.com. All tools run 100% in your browser — no signup, no data sent to servers.