Format and validate XML
XML is still everywhere: sitemaps, RSS and Atom feeds, SOAP APIs, Android layouts, Maven and .NET project files, SVG graphics, office documents and countless configuration and data-exchange formats. Machine-generated XML usually comes as a single long line that's almost impossible to read. This XML formatter indents it neatly so you can see the structure, checks that it's well-formed, and can also minify it to save space.
Features
- Beautify with 2 spaces, 4 spaces or tabs.
- Minify to remove whitespace between tags.
- Well-formedness check with the parser's error message.
- Keeps comments, CDATA, DOCTYPE and the XML declaration.
- Compact output for elements that contain only text, such as
<title>Midnight Rain</title>. - Copy or download the result as an
.xmlfile. - Private: runs entirely in your browser.
Common XML errors
| Error | Example | Fix |
|---|---|---|
| Unclosed tag | <item>text |
Add </item> |
| Mismatched tags | <a><b></a></b> |
Close tags in reverse order |
| Unescaped ampersand | Tom & Jerry |
Write Tom & Jerry |
| Unquoted attribute | <price currency=USD> |
<price currency="USD"> |
| Several root elements | <a/><b/> |
Wrap them in one root element |
| Text before the declaration | <?xml ...?> |
The declaration must be the very first thing |
Related tools
Working with other formats? Pretty-print JSON with the JSON Formatter, convert configuration files with YAML to JSON, or compare two XML files line by line with the Diff Checker.