Categories

XML Formatter

Format and validate XML data

Mode

XML Formatter and Validator Online

This free XML formatter pretty-prints XML documents with consistent indentation and checks them for well-formedness as it goes. Paste minified or messy XML — API responses, SOAP envelopes, RSS feeds, SVG markup, or Maven and Android configuration files — and get a readable, properly nested version instantly.

Parsing and formatting run in your browser using the standards-based DOM parser, so documents are validated the same way browsers read XML, and nothing you paste is uploaded anywhere.

How to use XML Formatter

  1. Paste your XML document into the input box.
  2. The formatted output appears automatically as you type or paste.
  3. If the document is not well-formed, the parser error is shown instead, describing what is wrong.
  4. Copy the formatted XML with the copy button.

What is well-formed XML?

An XML document is well-formed when it follows the core syntax rules: exactly one root element, every opening tag matched by a closing tag, proper nesting, quoted attribute values, and escaped special characters (& as &amp;, < as &lt;). Well-formedness is the minimum bar for any parser to read the document at all — this tool detects violations and reports the parser's error message.

<catalog>
  <book id="1">
    <title>XML Basics</title>
    <price>9.99</price>
  </book>
</catalog>
A small, well-formed XML document with 2-space indentation.

Why format XML?

XML arrives minified from APIs, serialized by tools, or hand-edited into a tangle of nested tags on a single line. Formatting reveals the document tree — which elements contain which, where attributes sit, and where a branch begins and ends — so you can review SOAP envelopes, debug RSS and Atom feeds, read Maven or Android configuration, and inspect SVG source without fighting the whitespace. Consistent indentation also produces cleaner diffs in version control.

Well-formed vs valid XML

The two terms are easy to confuse. A document is well-formed when it obeys XML's syntax rules — one root element, correctly nested and closed tags, quoted attribute values, and escaped special characters. A document is valid when, in addition to being well-formed, it conforms to a schema (XSD) or DTD that defines which elements and attributes are allowed and in what order. This tool checks well-formedness, the requirement every XML parser enforces; it does not validate against a schema.

Related terminology

Element
A unit of XML structure delimited by an opening and closing tag, such as <title>…</title>, optionally containing attributes, text, and child elements.
Well-formed
Following XML's syntactic rules (matching tags, single root, quoted attributes). Distinct from valid, which additionally means conforming to a schema or DTD.
Attribute
A name="value" pair inside an element's opening tag, used for metadata like ids and language codes.
Namespace
A mechanism (xmlns) for qualifying element names so vocabularies from different XML standards can be mixed in one document.

Frequently asked questions

How do I pretty-print XML online?
Paste the XML into the input box — the tool re-indents it automatically with one element per line and nested children indented, ready to copy.
Does this tool validate my XML?
It checks well-formedness: unclosed tags, mismatched nesting, bad entities, and similar syntax errors are reported with the parser's message. It does not validate against a DTD or XML Schema.
Why does my XML fail to parse?
The most common causes are an unescaped ampersand (& must be written &amp;), mismatched or unclosed tags, multiple root elements, and unquoted attribute values.
What is the difference between well-formed and valid XML?
Well-formed means the document follows XML's syntax rules (single root, matched and nested tags, quoted attributes, escaped entities). Valid means it is well-formed and also conforms to a schema or DTD. This tool checks well-formedness, not schema validity.
Can I format SVG, RSS, or SOAP with this tool?
Yes. SVG images, RSS and Atom feeds, and SOAP envelopes are all XML, so they pretty-print the same way — as long as the markup is well-formed.
Is my XML uploaded to a server?
No — parsing and formatting happen entirely in your browser, so the tool is safe for internal API payloads and configuration files.

Related tools