XML Formatter
Indent XML so its structure is easy to follow, and find out immediately if it is not well-formed. The same tool minifies XML when you need it compact.
- Runs in your browser
- No sign-up
- Free to use
How to use XML Formatter
- Paste XML into the input editor or open an .xml file.
- Choose the indentation you prefer.
- Select Format to pretty-print or Minify to remove whitespace between tags.
- If the XML is not well-formed, read the error and the highlighted line, fix it and try again.
XML Formatter features
Well-formedness check
Reports unclosed tags, mismatched names and illegal characters with the line where parsing failed.
Structure-aware indentation
Child elements are nested one level deeper; elements that contain only text stay on one line.
Everything preserved
Comments, CDATA sections, processing instructions, namespaces and the DOCTYPE are kept as written.
Minify mode
Remove whitespace between elements, and optionally comments, for compact output.
Any XML dialect
Works with SOAP envelopes, RSS and Atom feeds, sitemaps, SVG, Android layouts, Maven and .NET config files.
Local processing
Documents are parsed in your browser.
When to use XML Formatter
- Reading a SOAP or REST XML response returned as a single line.
- Checking a sitemap or RSS feed before publishing it.
- Tidying configuration files such as pom.xml, web.config or AndroidManifest.xml.
- Finding the unclosed tag that makes an import fail.
XML Formatter FAQ
What does “well-formed” mean?
A well-formed document follows XML's syntax rules: one root element, every opening tag closed, tags properly nested, attribute values quoted, and special characters such as & escaped. It is the minimum requirement for any XML parser to accept the document.
Does it validate against a schema or DTD?
No. Schema validation (XSD, DTD, RELAX NG) checks that the right elements appear in the right places and needs the schema file. This tool checks syntax only.
Does formatting change the data?
It adds or removes whitespace between tags. For data-oriented XML that is insignificant. In documents with mixed content, where text and elements are interleaved, whitespace can be meaningful, so review the result for such files.
Why is my & character causing an error?
In XML a bare ampersand starts an entity reference. Write & for a literal ampersand, and similarly < for a less-than sign.
Can it format HTML?
Only if the HTML is also valid XML (XHTML). Ordinary HTML allows unclosed tags such as <br> and will be reported as not well-formed. Use the HTML Formatter for that.
XML rules in brief
XML is strict by design. Where HTML parsers guess at what an author meant, an XML parser must stop at the first error. That makes XML dependable for exchanging data between systems, and it makes a single missing slash fatal. The most common mistakes are an element that is opened but never closed, closing tags in the wrong order, unquoted attribute values and unescaped ampersands.
Because a document is a tree of elements, indentation by depth is the natural way to display it. This formatter writes each element on its own line, indented under its parent, and keeps short text-only elements such as <name>Ada</name> on a single line so the output stays compact and readable.