XML formatter and validator

Paste XML to get it indented and readable, or minified to save space. It is checked at the same time, and a malformed document is reported with the reason.

  • Free
  • No sign-up
  • Runs in your browser
xml-formatter

100% private — your text is processed in your browser and never sent to any server.

How it works

Paste your XML

An API response, a configuration file, a feed, a sitemap or an export.

Choose format or minify

Pick the indentation, or remove all the whitespace.

Copy the result

If the XML is not well formed, the reason is shown.

Readable XML, or as small as it can be

XML often arrives on a single line, machine-generated and impossible to read: a SOAP response, a sitemap, an RSS feed, an Android layout, a Maven file or an export from an accounting program. Formatting adds line breaks and indentation so the structure is visible, and minifying does the opposite for storage or transmission. Either way, it helps to know at once whether the document is well formed.

Formatting

The formatter indents every nested element by the number of spaces you choose, or with tabs, and puts each element, comment and processing instruction on its own line. Attributes are kept in their original order and their values are escaped correctly. Elements that contain only text stay on a single line, and elements that mix text and other elements, such as a paragraph with a bold word, are left inline so that the meaning of the content, and the spaces that matter in it, are not changed. Comments, CDATA sections, the XML declaration and the document type declaration are all kept.

Minifying

Minifying removes the whitespace that only exists to make the document readable, the line breaks and indentation between elements, while keeping the text content as it is. The tool shows the size before and after so that you can see how much is saved.

Well-formedness check

Before doing anything, the document is parsed according to the XML rules. A tag that is not closed, elements that overlap, an attribute without quotes, an unescaped ampersand or a document with two roots all produce a message that names the problem and where it is. Well-formed means correct syntax; it does not mean the document follows a particular schema.

What it does not do

It does not validate against an XSD or DTD, it does not resolve entities defined in a DTD, and the declaration of a document type may be simplified. It does not change namespaces or reorder attributes. For very large files the browser's memory is the limit. For JSON, use the JSON formatter.

Frequently asked questions

How do I format XML?
Paste the XML and copy the result. It is indented with the number of spaces you choose.
How do I check that XML is valid?
The document is checked as it is formatted. If it is not well formed, you get the reason and the location of the problem.
Does it keep comments and CDATA?
Yes. Comments, CDATA sections, processing instructions and the XML declaration are kept.
Can I minify XML?
Yes. Choose "Minify" and the whitespace between elements is removed.
Does it validate against a schema?
No. It checks that the XML is well formed, not that it follows an XSD or DTD.
Is my XML uploaded anywhere?
No. It is processed in your browser.