All ToolsDeveloper & Data › XML Formatter

XML Formatter

Format, minify, and validate XML. View parsing errors and stats.

About this tool

This XML formatter beautifies XML with proper indentation, minifies it to remove whitespace, and validates it using the browser's built-in DOMParser. Everything runs locally in your browser.

The validator uses XML parsing (application/xml MIME type) which catches common errors like unclosed tags, mismatched tags, and invalid characters.

Frequently asked questions

What encoding does this support?

The tool handles UTF-8 XML which is the standard. It preserves the XML declaration if present but normalizes encoding to UTF-8 in output.

Why does validation fail?

Common reasons: unclosed tags, mismatched tag names, invalid characters (use & for &), duplicate attributes, or incorrect DOCTYPE. The error message will show the line and column.

Can I format XML with namespaces?

Yes. The tool handles XML namespaces correctly, preserving prefix prefixes and URIs.