How to Use the XML Formatter: Steps and a Worked Example
Pretty-print or minify XML and catch unclosed or mismatched tags. This guide shows what to enter, a worked example, and the limits to keep in mind. The XML Formatter tool is free, needs no account and runs in your browser.
What you need
- Paste XML
- Output: choose Pretty-print, Minify
- Indentation: choose 2 spaces, 4 spaces, Tab
Step by step
- Open the XML Formatter tool.
- Fill in Paste XML.
- Choose Output.
- Choose Indentation.
- Read the result, which updates as soon as the inputs change.
Worked example
With these inputs:
- Output: Pretty-print
- Indentation: 2 spaces
the tool returns:
<?xml version="1.0"?>
<catalog>
<book id="1">
<title>Dune</title>
<price>9.99</price>
</book>
</catalog>
How it works
Tokenizes tags and text, tracking a stack of open elements. Paste your XML, choose pretty print or minify and the indent size, then copy the result. Errors in tag nesting are reported instead of output.
Things to keep in mind
Checks tag nesting only. It does not validate against a schema or DTD, or expand entities.
Related tools
If this is not quite what you need, try JSON Formatter, CSS Formatter or HTML Formatter.