XML Formatter
Format, validate and minify XML with syntax highlighting, entirely in your browser.
Input
Output
How to use the XML Formatter
- Paste XML into the input editor, or click Sample for a Maven
pom.xml. - Choose Format to pretty-print with 2 spaces, 4 spaces or tabs, or Minify to remove the whitespace between elements.
- If the XML isn't well-formed, the problem line is highlighted with an explanation and a hint.
- Copy the result or Download it as an
.xmlfile.
Nothing is rewritten
Many XML formatters parse the document into objects and rebuild it, which can drop comments, reorder attributes, change quotes or expand entities. This one only changes indentation between elements. Tags, attributes, entities like &, comments, CDATA sections, processing instructions and the DOCTYPE are copied exactly.
Whitespace that matters is left alone: elements that contain only text, mixed content such as <p>Hello <b>world</b></p>, and anything marked xml:space="preserve".
What it checks
- Every opening tag has a matching closing tag, in the right order
- Attribute values are quoted, and no attribute is repeated
- Special characters are escaped:
&as&and<as< - The document has exactly one root element
Frequently asked questions
Is my XML uploaded?
No. Formatting and validation happen entirely in your browser. SOAP payloads, configs and feeds never leave your machine.
Does it validate against an XSD or DTD schema?
Not yet. It checks that the XML is well-formed, meaning correctly structured. Schema validation (whether the elements and values are the ones a schema allows) is a separate step.
Can it format Maven, Spring, Android or SOAP files?
Yes. Any well-formed XML works, including namespaces like xmlns:soap and XML declarations.
Related tools
All tools- JSON FormatterFormat, validate and minify JSON with syntax highlighting and precise error locations.
- Diff CheckerCompare two texts side by side or as a unified diff, with added, removed and changed lines.
- JSON ValidatorValidate JSON, see the exact line and column of syntax errors, and fix common mistakes.
- JSON MinifierRemove whitespace from JSON and see the original size, minified size and savings.
- JSON ↔ YAML ConverterConvert JSON to YAML and YAML to JSON without losing large numbers, with anchors, merge keys and safe quoting.