Developer tools

XML Formatter

XML Formatter

Pretty-print, minify and validate XML with line and column errors.

About this tool

About XML Formatter

Paste XML from a SOAP response, an RSS or Atom feed, an Android layout, a Maven pom.xml, an SVG or a sitemap and get it back cleanly indented, one element per line, with short text elements kept on a single line so the structure is easy to scan. Pick 2 spaces, 4 spaces or tabs, and put each attribute on its own line when tags get long. Minify does the opposite: it removes whitespace between tags and, if you like, comments, for smaller payloads. Before formatting, the document is checked for well-formedness, and problems are reported with a line and column and a plain explanation: a closing tag that does not match, a second root element, an unescaped & or <, a duplicate attribute or an unknown entity such as &nbsp;. CDATA sections, comments, processing instructions and the DOCTYPE are preserved exactly. Everything runs in your browser, so internal service payloads are never uploaded. If the XML is broken, optional AI help can propose a minimal fix using your own AI key; only the XML is sent, straight to your provider.

Built and maintained by Abhi JainUpdated

How to Format XML

  1. 1

    Paste or open XML

    Paste XML into the left pane, open an .xml, .svg or feed file, or click Sample.

  2. 2

    Choose Format or Minify

    Under Mode pick Format, then choose the Indentation and whether to put one attribute per line, or pick Minify to strip whitespace.

  3. 3

    Fix errors and copy

    If the XML is malformed, fix the line and column shown, then copy or download the result.

XML Formatter: questions and answers

What does well-formed XML mean?

Every opening tag has a matching closing tag with exactly the same case, elements nest without overlapping, there is exactly one root element, attribute values are quoted, and & and < in text are escaped as &amp; and &lt;. A well-formed document can be read by any XML parser.

Why is &nbsp; an error in XML?

XML only predefines five entities: &amp;, &lt;, &gt;, &quot; and &apos;. &nbsp; comes from HTML. Use the numeric reference &#160; instead, or declare the entity in a DOCTYPE.

Does formatting change my data?

Formatting only adds or removes whitespace between tags. Text inside elements is trimmed for display, and CDATA sections are kept byte for byte. If whitespace inside mixed content matters to you, check the output before replacing the original.

Can it check my XML against an XSD schema?

No. It checks that the XML is well-formed, which is what most errors are. Validating against an XSD or DTD needs the schema files and a validating parser.

Is my XML uploaded?

No. Parsing and formatting run entirely in your browser.

Can AI fix malformed XML?

Yes, optionally. With your own AI key connected in AI settings, the AI button sends the XML and the parser's error to your provider and returns a minimally corrected version with a list of changes. You choose whether to replace the input; validation and formatting still run locally.

Ready-made XML Formatter presets