RSRobince Studio

XML Formatter & Validator

Paste XML to pretty print it with consistent indentation, minify it to a single line, and check at the same time that it is well-formed. All processing stays in your browser.

Runs in your browser. Your files are never uploaded.

Loading XML Formatter & Validator…

How to use XML Formatter & Validator

  1. Paste your XML into the left box, or press Load sample.
  2. Choose Pretty print or Minify, and for pretty print pick 2 spaces, 4 spaces or a tab.
  3. If the XML is invalid, read the error message to find the problem; if valid, a confirmation appears.
  4. Copy the result or download it as formatted.xml.

Why format XML

XML exported by software is often one long line, or indented inconsistently after being edited by several tools. That makes it hard to read, hard to review in a diff and easy to break when editing by hand. Consistent indentation shows the nesting of elements at a glance and makes mistakes such as a misplaced closing tag obvious.

The opposite operation is just as common. Minified XML removes the whitespace between tags, which makes payloads and embedded configuration smaller to store and transmit.

Common well-formedness errors

XML is stricter than HTML. A single problem makes the whole document invalid, and a good error message saves a lot of time. The most frequent causes are listed below.

  • A missing or mismatched closing tag. Tag names are case-sensitive, so <Item></item> is an error.
  • A raw ampersand or less-than sign in text. Write &amp; and &lt; instead.
  • Attribute values without quotes, or the same attribute twice on one element.
  • More than one root element, or text outside the root.
  • Using a namespace prefix that has not been declared.

Tips and limits

When the output says the XML is valid, you know the syntax is right, but the document may still be wrong for its purpose, since business rules and schemas are not checked. For SOAP messages, sitemaps, Android layouts, SVG and similar formats, use the formatter first to read the structure, then check against the format’s own documentation or schema tools.

Mixed content, where text and child elements are interleaved, is placed on separate lines when pretty printing, which can add visible whitespace in documents where text flow matters. In that case use the minified output or edit the original. The tool never sends your XML to a server, so it is suitable for private data.

Why use this xml formatter & validator tool

  • Pretty print or minify. Make unreadable one-line XML easy to read, or strip whitespace to shrink it.
  • Well-formedness check. Uses the browser’s strict XML parser to confirm tags are balanced and syntax is correct.
  • Preserves content. Attributes, CDATA, comments, processing instructions and the XML declaration are kept.
  • Offline-friendly and private. Nothing is uploaded; your XML is processed on your device.

Frequently asked questions

What does validate mean here?

The tool checks that the XML is well-formed: one root element, properly nested and closed tags, quoted attributes and correctly escaped characters. It does not check the document against a schema (XSD) or DTD, which is a separate kind of validation.

Will formatting change my data?

Formatting only changes whitespace between elements. Whitespace-only text nodes are removed and the text inside elements is trimmed at its edges. If your document relies on significant whitespace, such as inside xml:space="preserve" blocks, compare the result carefully.

Why does the declaration or DOCTYPE look different?

The XML declaration is kept as you wrote it. A DOCTYPE is rebuilt from its name and identifiers, and any internal subset declarations inside square brackets are not reproduced.

More free tools