Structured Data

XML Formatter & Validator

Paste XML to pretty-print or compact it and pinpoint malformed markup with a line, a column and the surrounding source. Everything runs in your browser — your document never leaves the page.

Runs in your browser v1.0.0

Options

live

XML input

paste or type

Checked with a built-in well-formedness parser. Tags, attributes and errors are reported with line and column instead of failing silently.

Formatted output

live


                

How it works

The input is tokenised and checked for XML well-formedness in this tab, then re-indented or compacted from the parsed tree. When markup is malformed the offending line, column and source excerpt are shown so you can fix it quickly, and a best-effort format is still produced when the structure is recoverable. Compact mode only removes whitespace that sits between tags, so text content is never altered. Nothing is uploaded and no network request is made.

Practical uses

Pretty-print or compact XML and check it for well-formedness, reporting the first error with a line and column.

Common ways to use it

  • Re-indent a minified or single-line XML document to read its structure.
  • Check a config or SOAP payload for unclosed, mismatched, or duplicate tags before use.
  • Compress XML by removing whitespace between tags while keeping text content intact.

Malformed XML: mismatched closing tag

Input

<root>
  <a>x</a>
  <b>y</root>

Output

Malformed XML at line 3, column 7 — Mismatched closing tag </root> — expected </b> (opened at line 3, column 3).

Verified with the tool's analyze and formatError functions using the default options. The best-effort output is "<root>\n <a>x</a>\n <b>y</b>\n</root>". A valid document such as <a><b>1</b><c d="2"/></a> returns a valid state and formats with 3 elements, 1 attribute and depth 2.

Options that matter

  • Indentation — 2 spaces, 4 spaces, or a tab; ignored and disabled in compact mode.
  • Output — Pretty print indents the tree; Compact removes only whitespace that sits between tags.

Things to keep in mind

  • It checks XML well-formedness, not a DTD or schema, so it does not verify element names, attribute grammar, or document structure against a specification.
  • Compact mode removes whitespace between tags but leaves text content and mixed content exactly as written.
  • An unterminated comment, CDATA section, or processing instruction is fatal and produces no output.
  • Validation runs in the browser; no request is made to a server.