XML Formatter

Indent XML so it can be read, minify it back down, and see exactly where it stops being well-formed.

Result

Processed on your device. This file is never uploaded.

  1. 1Paste your XML into the left box.
  2. 2Choose Beautify to indent it, or Minify to strip it down.
  3. 3Copy the result — or fix the line the error points at.

Well-formed versus valid

These two words mean different things in XML and the distinction is worth having. A well-formed document obeys the syntax rules: every tag closes, tags nest without overlapping, attribute values are quoted, and reserved characters are escaped. A valid document is well-formed and conforms to a schema that says which elements may appear where.

This tool checks the first. It is the check that matters day to day, because a document that is not well-formed cannot be parsed at all — every XML library will reject it before your schema ever gets a look in.

The two errors that account for most of them

An unescaped ampersand is the classic. In XML, &starts an entity reference, so a bare one in text content — Smith & Sons — is a syntax error. It must be written as &amp;. The same applies to <, which has to be &lt;.

The other is case. Unlike HTML, XML tag names are case-sensitive, so <Book> and </book> are two different tags and the parser reports a mismatch that can look invisible when you are skimming.

Why the formatter is deliberately tolerant

The indenter lays out broken XML rather than refusing to touch it. That is intentional: when you are trying to find an unclosed tag, seeing the document indented is exactly what shows you where the nesting goes wrong. The validation result sits alongside the output rather than replacing it.

Frequently asked questions