XML Formatter

Format, minify and validate XML

XML Formatter
InputChars: 190
<?xml version="1.0" encoding="UTF-8"?>
<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><price currency="USD">44.95</price></book></catalog>
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<price currency="USD">44.95</price>
</book>
</catalog>
Valid XMLLines: 8Chars: 2125 elements

Tool guide

About XML Formatter

An XML formatter turns minified or machine-generated XML into clearly indented markup you can actually read.

Paste an API response, a config file, or a SOAP envelope, then beautify it, minify it back to one line, or browse it as a collapsible tree.

How to use the XML Formatter

  1. Paste your XML, or upload a .xml file.
  2. Click Format to pretty print with 2-space, 4-space, or tab indentation, or Compress to strip whitespace.
  3. Switch to Tree view to collapse branches, or read the error banner if the document is not well-formed.

When you would use it

  • Read a single-line XML response copied out of a log or a network tab.
  • Inspect a deeply nested SOAP envelope or RSS feed without counting closing tags by hand.
  • Find the exact line and column of a mismatched tag before committing a config file.

XML syntax, namespaces, and what formatting cannot fix

Formatting only changes whitespace between nodes. It never rewrites your data, and it cannot make an invalid document valid.

  • Every element needs a matching closing tag, and tag names are case-sensitive: <Book> and <book> are different elements.
  • Attribute values must be quoted, and namespace prefixes such as meta: must be declared with an xmlns attribute.
  • Text inside CDATA sections is preserved verbatim, so markup-looking content there is never reindented.

XML Formatter FAQ

Is an XML beautifier the same as an XML pretty printer?
Yes. Beautify, pretty print, and format all describe the same operation: adding line breaks and indentation without changing the data.
Does formatting change my data?
No. Only whitespace between nodes changes. Element order, attributes, and CDATA content stay exactly as they were.
Is my XML uploaded to a server?
No. Parsing, formatting, and validation all run locally in your browser and nothing is sent to wetool.site.

XML Formatter vs XML Schema validation

This tool checks that your document is well-formed: tags match, quotes close, and nesting is legal. It does not check your XML against an XSD or DTD, so a well-formed document can still violate its schema.

Reading XML as a collapsible tree

An XML viewer shows structure instead of text. Tree view is the fastest way to understand an unfamiliar document, because you can collapse the branches you do not care about.

  • Each element becomes a node showing its tag name and attributes, so you can see the shape of the document at a glance.
  • Collapsing a branch hides an entire subtree, which makes repeated records such as <book> or <item> easy to compare.
  • Sibling order is preserved exactly as written, and elements sharing a name are never merged together.

Validating XML and reading the error

An XML validator reports the first place the document stops being well-formed, with a line and column you can jump to.

  • A mismatched tag error names both the closing tag it found and the line where the opening tag was declared.
  • Unquoted attribute values and stray < or & characters are the two most common causes of a failed parse.
  • Line and column numbers are computed by the parser itself, so they stay identical across Chrome, Firefox, and Safari.