All tools run in your browser — your files never leave your device.
All tools154

Developer & Security

XML Formatter

Pretty-print, minify and check XML is well-formed.

What it does. Formatting XML re-indents it to show nesting without changing what it means. Whitespace between elements is usually insignificant, so indentation is free — but whitespace inside a text node is content, which is why a formatter must not reflow element text.
Runs in your browserNothing uploadsNo signupWorks offline

How to use XML Formatter

  1. Paste XML, or drop a file in.
  2. Choose format or minify, and set the indent.
  3. Copy the result or download it.

Well-formed is not the same as valid

Well-formed means the syntax holds together: one root element, every tag closed, correct nesting, attributes quoted. That is what this tool checks.

Valid means the document also conforms to a schema — a DTD, XSD or RelaxNG — which specifies which elements may appear where, and what types their values take.

A document can be perfectly well-formed and still be rejected by the system expecting it, because it puts the right syntax in the wrong shape. If a payload is refused despite formatting cleanly, the schema is where to look.

Where whitespace matters

Between elements, whitespace is usually ignorable, so indentation can be added and removed freely. Inside a text node it is content, and reflowing it changes the data.

The exception is xml:space="preserve", which explicitly marks a section whose whitespace must survive untouched.

This is why formatting a document containing embedded code, poetry or pre-formatted text can silently corrupt it. This tool indents structure without reflowing text nodes, but a document relying on significant whitespace is worth checking after any reformat.

The five characters that must be escaped

The five characters that must be escaped
CharacterEntityRequired
&&Always
<&lt;Always
>&gt;In content, by convention
"&quot;Inside double-quoted attributes
apostrophe&apos;Inside single-quoted attributes

An unescaped ampersand is the single most common cause of an XML parse failure, because it appears constantly in URLs. A query string dropped into an element without escaping breaks the document at the first parameter separator.

Frequently asked questions

What is the difference between well-formed and valid XML?

Well-formed means the syntax holds together — one root, tags closed, correct nesting, attributes quoted. Valid means it also conforms to a schema. A document can be well-formed and still rejected for having the wrong shape.

Does formatting change my XML?

It changes whitespace between elements, which is normally insignificant. Text inside elements is content and is not reflowed. Sections marked xml:space="preserve" need care after any reformat.

Why does my XML fail to parse?

An unescaped ampersand is the most common cause, because URLs are full of them. A raw ampersand must be written as an entity, along with the less-than sign inside content.

Can XML have more than one root element?

No. Exactly one root element is required, and multiple top-level elements are the second most common well-formedness failure after unescaped ampersands.

Is my XML uploaded anywhere?

No. Parsing and formatting run in your browser, which matters because the XML people format is usually a config file, an invoice or an API payload.