How to use the XML formatter
- Paste your XML into XML input, or select Load example.
- Select Format (or press Ctrl+Enter) to indent it, or Minify to remove the whitespace between elements.
- Choose 2 spaces, 4 spaces or tabs for indentation.
- Copy the result or download it as an
.xmlfile.
The formatter also checks that the XML is well-formed. If it isn't, you'll see the line and column of the first problem with an explanation; select Go to error to jump to it.
What changes, and what doesn't
Only the indentation between elements changes. Everything else is kept exactly as you wrote it:
- attribute values, their quote style (
"or') and their order; - text, entity references such as
&and©, and CDATA sections; - comments, processing instructions, the XML declaration and the DOCTYPE.
Whitespace can be meaningful in XML, so some elements are deliberately left untouched: elements that mix text and markup (such as <p>Hello <b>world</b></p>), elements that contain only text, and anything inside xml:space="preserve".
Errors it explains
- Mismatched or unclosed tags, including where the open element started (tag names are case-sensitive)
- More than one root element, or text outside the root
- Unquoted, duplicate or valueless attributes
- Unescaped
<and&in text and attribute values - Undeclared entities such as
, which HTML has but XML doesn't (use ) - Malformed comments, CDATA sections and declarations
Frequently asked questions
Is my XML uploaded?
No. Formatting and checking run entirely in your browser; nothing you paste is sent to our servers or logged.
Does it validate against a schema (XSD) or DTD?
No. It checks that the XML is well-formed, which is what every XML parser requires. Validating against an XSD or a DTD is a separate, stricter check.
Can I format SOAP messages, XAML, SVG or .csproj files?
Yes. They're all XML, and namespace prefixes such as soap: are kept as written.