T
Loading editor…
Ln 1, Col 10 B
Formatted output
Formatted output appears here.
Everything runs in your browser — nothing is uploaded.

XML Formatter & Validator

Paste minified or badly indented XML and get back a properly nested document, with a well-formedness check that reports mismatched and unclosed tags by line and column.

The formatter re-indents a token stream instead of parsing into a document object and serialising it back out. That is a deliberate choice: a round-trip through a DOM silently rewrites attribute quoting, reorders or normalises attributes, drops comments and converts CDATA into escaped text. When you are inspecting a SOAP response or a signed document, those details are exactly what you need to see unchanged.

How to use it

  1. Paste XML on the left, or press Sample for an example with namespaces and a CDATA block.
  2. Pick an indent width; the formatted document appears on the right as you type.
  3. Use Minify to strip insignificant whitespace between tags, or Format in place to replace your input with the formatted version.
  4. Check the status bar for well-formedness, and click any reported problem to jump to it.

What is preserved exactly

Attribute order and quoting style survive untouched, as do comments, the XML declaration, DOCTYPE declarations including internal subsets, processing instructions and namespace prefixes. CDATA sections are copied through byte for byte, so markup and ampersands inside them stay literal.

Short text-only elements such as <title>XML Developer's Guide</title> are kept on a single line rather than exploded across three, which keeps a formatted document scannable.

Well-formedness checking

The validator tracks open elements and reports a closing tag that does not match the element it closes, a closing tag with no opening tag, and any element left unclosed at the end of the document. Each problem carries a line and column so you can jump to it.

A '>' inside an attribute value does not end a tag, so documents containing markup in attributes are handled correctly rather than being mis-split.

Frequently asked questions

Will formatting reorder or rewrite my attributes?

No. Attributes keep their original order and quoting, because the formatter never rebuilds elements from a parsed model — it only changes the whitespace between tokens.

Are CDATA sections and comments kept?

Yes, both are copied through verbatim. CDATA contents are never escaped or unescaped, and comments are preserved in place.

Does it validate against a DTD or XSD?

No. It checks well-formedness — that tags are balanced and correctly nested — not validity against a schema. Schema validation requires fetching and processing the schema, which would mean sending your document somewhere.

Can it convert XML to JSON?

Yes, through the dedicated JSON ↔ XML converter, which maps elements to keys and exposes attributes with an @_ prefix.

Related tools

Everything on this page runs in your browser. TurboParse is a static site with no backend, so nothing you paste is uploaded, logged or stored.

Last updated .