XML Formatter
Paste XML to check it and lay it out with clear indentation.
INPUT
CHARS: 0WORDS: 0LINES: 0
OUTPUT
CHARS: 0WORDS: 0LINES: 0
How the XML Formatter works
The document is first checked with the browser's XML parser, so only well formed XML is formatted and a malformed tag, a mismatched closing tag or an unescaped ampersand is reported instead of being silently accepted. Beautify mode then indents nested elements and puts short text only elements on a single line. Comments, CDATA sections, processing instructions and the XML declaration are preserved.
Minify mode removes whitespace between tags while leaving text content alone.
XML Formatter examples
Sample input with the default options
Input
<?xml version="1.0"?><catalog><book id="1"><title>Dune</title></book></catalog>
Result
<?xml version="1.0"?> <catalog> <book id="1"> <title>Dune</title> </book> </catalog>
When it is useful
- •Reading SOAP responses, RSS feeds and sitemaps.
- •Validating a config or data file before importing it.
- •Shrinking XML before embedding it in a request.
- •Preparing a readable snippet for documentation.
Frequently Asked Questions
Does it validate against a schema?
No. It checks that the XML is well formed but does not compare it with an XSD or DTD.
Will formatting change the data?
Whitespace in element content might be trimmed when text is moved onto one line. For mixed content, such as text with inline tags, check the result.
Can it handle namespaces?
Yes. Prefixes and namespace declarations are kept exactly as written.
Related tools
- HTML Formatter, Minifier and BeautifierClean up markup, or squeeze it down for production.
- JSON Formatter and MinifierPaste JSON to validate it and print it neatly, or compress it to a single line.
- JSON to YAML ConverterSwitch configuration between JSON and YAML in either direction.
- YAML FormatterCheck your YAML parses, and print it with consistent indentation.