XML Formatter
Format and minify XML — with validation and proper indentation
How to Use the XML Formatter
- Paste your XML.
- Choose Format or Minify mode.
- Select indent style and click Format.
Validates XML structure, formats with proper indentation, or minifies by removing whitespace and comments.
What is XML Formatting & Beautification?
The XML Formatter is a client-side beautifier and validator for Extensible Markup Language (XML). It parses raw, minified, or unformatted XML strings, cleans indentation hierarchies with customizable 2-space or 4-space tab stops, validates syntax, and highlights unclosed tags or structural errors with line numbers.
Common Uses
- Formatting unreadable minified SOAP responses and enterprise XML feeds
- Validating XML syntax and identifying mismatched or unclosed tags
- Cleaning Android manifest files, SVG graphics, and RSS/Atom feeds for code reviews
- Beautifying XML configuration files before committing to Git version control
Frequently Asked Questions
What makes an XML document 'well-formed'?
An XML document is well-formed if it has a single root element, all opening tags have matching closing tags, tags are properly nested, attribute values are enclosed in quotes, and special characters like `&` and `<` are properly escaped.
Can this formatter handle self-closing tags (like `
`)?
Yes. It correctly parses and preserves self-closing elements, CDATA blocks, XML processing instructions (``), and comments.
Does formatting modify my XML data or attributes?
No. The formatter only adjusts indentation and line breaks between elements. Element names, attribute pairs, and text node content remain completely untouched.
Notes from this implementation
Indent the tree you already have
The formatter parses XML and reprints it with indentation. It does not repair a missing close tag by guessing where it went. A parse error names the point the parser gave up. Fix that point before you look further down, because one unclosed element makes the rest of the document look wrong.
Attribute order and the quoting character may change. A canonical XML signature that covers the exact bytes will not survive a pretty print. Format a copy. Leave the signed document alone. Whitespace in text nodes can be significant in mixed content. If a paragraph’s spaces collapse, the formatter is treating them as insignificant and your document was not.