</>

XML Formatter w3c

Pretty-print or minify XML documents and check whether they are well-formed.

action
indent
INPUTxml
0 lines 0 chars
1
OUTPUTformatted
0 lines 0 chars
1
Tool Guide

What this tool does

XML expresses structured data with tags. Even in a world dominated by JSON it remains central to SOAP web services, RSS feeds, Android layouts, Maven and Spring configuration, and many document standards.

This tool applies indentation that follows the nesting of elements to make a document readable, and can also strip whitespace to compact it. Conversion checks that the document is well-formed: that opening and closing tags match, that elements nest correctly, that attribute values are quoted, and that special characters are escaped.

Well-formed is not the same as valid. Well-formed means the XML syntax rules are satisfied, while valid means the document also conforms to a DTD or XML Schema. Only the well-formed check is performed here.

When to use it

Use it to inspect SOAP request and response bodies, to review the structure of an RSS feed or sitemap, to expand a minified configuration file, or to locate the position of a parsing error.

Input and output examples

Input <root><item id="1">value</item></root>
Output <root> <item id="1">value</item> </root>

Indentation is applied per nesting level.

Input <root><item>A & B</item></root>
Output Well-formed error: & must be escaped as &amp;amp;

An ampersand starts an entity reference, so it cannot appear raw.

Notes and limitations

Ampersand, less-than, and greater-than have special meaning in XML and must be escaped as &amp;, &lt;, and &gt; when they appear in data; omitting this causes a well-formed error. Reformatting can also alter documents where whitespace is significant, such as mixed content with text nodes, so review the result before saving over the original.

Frequently asked questions

What is the difference between well-formed and valid?

Well-formed means the syntax rules are met; valid means the document also matches a DTD or schema. This tool checks well-formedness only.

Does reformatting change my data?

It can when whitespace between tags is significant. Pure data documents are usually safe, but mixed content should be reviewed.

Copied