How to Use the XML Formatter: Steps and a Worked Example

By 1 min read

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

  1. Open the XML Formatter tool.
  2. Fill in Paste XML.
  3. Choose Output.
  4. Choose Indentation.
  5. 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.

If this is not quite what you need, try JSON Formatter, CSS Formatter or HTML Formatter.

More from the blog