Skip to content

XML Formatter

Mode
Indent

XML

Result

Example

How to use

  1. 1.

    Paste your XML into the XML panel

  2. 2.

    Choose Format or Minify; when formatting, set Indent to 2, 4 or Tab - the Result panel updates as you type

  3. 3.

    Fix any error the Result panel shows, then copy or download the result

Common uses

  • ▸

    Formatting minified XML from an API response or configuration file

  • ▸

    Checking that XML is well-formed before using it in an application

  • ▸

    Minifying XML for storage or transmission efficiency

Frequently asked questions

Does the formatter validate XML?

It checks that the XML is well-formed, using the browser's built-in DOMParser. If it is not (a mismatched tag, an unescaped &, a second root element), the Result panel shows the error with its line and column; when it parses, the Result header shows Valid XML. It does not validate against a DTD or an XML Schema.


What indentation does it use?

Formatted output uses 2-space indentation by default; the Indent option switches to 4 spaces or tabs. Elements that contain text, such as <p>Hello <b>world</b>!</p>, are not re-indented, so their text and spacing do not change, and xml:space="preserve" is honoured. The XML declaration and DOCTYPE are kept as they appear in your input.


Is my data sent to a server?

Formatting runs entirely in your browser using the native DOMParser. No XML is transmitted anywhere.


What is the difference between XML and HTML?

XML is a strict, self-describing markup language where you define your own tags. HTML has a fixed set of tags with relaxed parsing rules. Well-formed XML must have a single root element and every tag must be properly closed.


Can I minify XML?

The Minify option removes the whitespace between elements, producing compact XML suitable for transmission. Text content, CDATA sections, comments and processing instructions are left untouched.