Free Online XML Formatter, Validator & Beautifier
Paste minified or messy XML and get it indented and readable in one click. The formatter validates as it parses, points at the first syntax error, and can minify the document again or convert it to JSON — all inside your browser.
What an XML Formatter Does
An XML formatter re-indents a document so its nesting becomes visible: every child element is pushed one level in from its parent, and elements that hold only text stay on a single line. Machine-generated XML — SOAP envelopes, RSS feeds, sitemaps, Android layouts, Maven POMs — usually arrives as one enormous line, which is fine for a parser and unreadable for a person. Formatting changes only whitespace between tags, so the document that comes out is the same document that went in.
How to Format XML Online
Four steps, no account and no upload:
- Paste your XML into the left panel, or load the sample to try the tool.
- Pick an indentation width — 2 spaces, 4 spaces or a tab character.
- Press Format. Invalid XML is rejected with the parser's own error message instead of a silent half-result.
- Copy or download the result, or switch to the second tab to convert the document to JSON.
Well-Formed vs Valid XML
Well-formed
The document follows XML syntax: one root element, every tag closed, tags nested in order, attribute values quoted, and reserved characters escaped. This is what a parser checks, and it is what this tool reports on.
Valid
The document is well-formed and also matches a schema — a DTD, XSD or RELAX NG grammar that says which elements may appear where. Validity needs that schema, so it is checked by your build or your editor, not by a browser-side formatter.
Common XML Errors and How to Fix Them
- Unclosed or mismatched tags — <item> closed by </Item>. XML is case-sensitive, unlike HTML.
- More than one root element. Wrap the siblings in a single container element.
- Raw & < or > inside text or attributes. Escape them as & < > or wrap the text in CDATA.
- Unquoted attribute values. Every attribute needs quotes: id="1", never id=1.
- An undeclared namespace prefix, such as soap:Body with no xmlns:soap declaration on an ancestor.