Paste a minified SOAP envelope, an RSS feed, or a 3,000-line Maven pom.xml and get clean, indented XML back. The formatter parses your input first, so a mismatched tag or a stray & comes back with the reason it broke instead of a blank screen. Beautify, pretty-print, or minify XML in the browser; nothing is uploaded.
Paste, pick an indent, format. Results in milliseconds.
.xml.Naive "format XML online" tools just re-space the text they are handed. This one parses the document first, so it beautifies the actual tree: elements indent under their parents, attributes stay on their tags, and if the XML is not well-formed you get the error instead of garbage. Beautifying never rewrites your data. Text nodes, attribute values, and element order come out identical; only the indentation between tags changes.
XML is stricter than the HTML most of us cut our teeth on. It is case-sensitive (<Book> and <book> are two different tags), it allows exactly one root element, and it wants reserved characters escaped as entities. Break any of those and the parser stops dead at that byte.
"Well-formed XML" means the syntax holds up: tags matched and nested, attributes quoted, entities escaped. "Valid XML" is stricter again, matching a schema (DTD, XSD, or RelaxNG) that dictates which elements may appear where. This formatter enforces well-formedness as it beautifies, which catches most real bugs. If you also work in JSON, the same idea powers the JSON parser and JSON formatter.
CDATA sections, which legitimately hold raw < and &.xmlns:soap and soap:Body.<?xml … ?> prolog and its encoding declaration.| Rule | Valid | Invalid |
|---|---|---|
| Case-sensitive tags must match | <Book></Book> | <Book></book> |
| Exactly one root element | <root><a/><b/></root> | <a/><b/> |
| Proper nesting (close in reverse) | <a><b/></a> | <a><b></a></b> |
| Attribute values quoted | <p id="1"> | <p id=1> |
| Reserved chars escaped in text | < & > | raw < and & |
| Construct | Handling |
|---|---|
Prolog <?xml version="1.0"?> | Kept on line 1 with its encoding declaration |
CDATA <![CDATA[…]]> | Left byte-for-byte; may contain < and & |
Namespaces xmlns:soap | Prefixes preserved verbatim on their elements |
Comments <!-- --> | Kept and re-indented |
Self-closing <br/> | Preserved, not expanded |
XML parsers are unforgiving: the first slip stops the parse, so you fix errors one at a time from the top. These five cover almost every "not well-formed" message.
| Parser says | What actually happened | Fix |
|---|---|---|
mismatched tag | Start and end tag differ, usually in case, because XML is case-sensitive | Make <Book> and </Book> match exactly |
junk after document element | Two elements at the top level with no wrapper | Wrap the siblings in one root element |
EntityRef: expecting ';' | A raw ampersand in text, e.g. the & in "AT&T" | Escape it as & |
AttValue: " or ' expected | An unquoted attribute like id=1 | Quote every value: id="1" |
Premature end of data | A tag opened and never closed before end of file | Close it, or self-close as <tag/> |
Beautifying and minifying are the same operation in reverse, and both are lossless. Beautify (pretty-print) while you read a SOAP trace or eyeball an Android strings.xml; minify before you send XML over the wire, where every space is bandwidth. Hit Minify above to collapse an indented document back to one line. It is the XML counterpart to the JSON minifier and JSON pretty-printer, so the workflow is identical whichever format your API speaks.
Reading and debugging XML is where this earns its keep.
<description>.pom.xml, web.config, Spring beans, Android layouts: reindent and sanity-check.What developers ask about formatting XML.
<Book> and </book> are different tags; the rest of the time tags were closed in the wrong nesting order.xmlns:soap and prefixed names like soap:Envelope are kept verbatim, CDATA is left intact, and the <?xml?> prolog stays on line one. Paste RSS 2.0, Atom, or a WSDL and it indents cleanly.DOMParser in your own browser. Your XML never touches a server, which matters for config files and API payloads that carry keys or tokens.Hands-on articles from our blog.
Half of XML work ends in JSON. These free, browser-based tools pair well with this formatter.