Developer tools

XML formatter and validator

Check that XML is well-formed, then pretty-print or minify it without touching text content.

XML formatter and validator
Esc to restore

Your inputs

Up to 2 MB.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded or saved.

A clear answer. Here’s how.

A strict parser checks the XML 1.0 well-formedness rules: names, matching start and end tags, a single root element, quoted attribute values without duplicates or “<”, legal characters, comments without “--”, processing instructions, CDATA sections, the five predefined entities and valid numeric character references. Errors give the line and column. Formatting only rewrites white space between elements, comments and instructions: an element that contains text keeps that content exactly, so mixed content such as <p>Hello <b>world</b></p> is never altered. DOCTYPE internal subsets are refused because entity declarations can expand into enormous documents. Namespace prefixes are not resolved and no schema is checked.

How this is checked

4 reference checks passed These 4 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.

See the checks and where each expected answer comes from
  1. Case 1

    Inputs
    XML <a><b>1</b><c x="2"/></a>Output prettyIndent 2Comments keep
    Expected, and what Toolmoz gave
    text expected <a> <b>1</b> <c x="2"/> </a> , Toolmoz <a> <b>1</b> <c x="2"/> </a> Elements expected 3, Toolmoz 3Attributes expected 1, Toolmoz 1Maximum nesting depth expected 2, Toolmoz 2Root element expected a, Toolmoz a
    Where the expected answer comes from
    Hand-formatted: element-only content gets one child per line, indented two spaces; three elements, one attribute, depth two
    Allowed difference
    exact
  2. Case 2

    Inputs
    XML <a> <b>1</b> <!-- n --> <c/> </a>Output minifyIndent 2Comments keep
    Expected, and what Toolmoz gave
    text expected <a><b>1</b><!-- n --><c/></a>, Toolmoz <a><b>1</b><!-- n --><c/></a>Comments expected 1, Toolmoz 1
    Where the expected answer comes from
    Minifying removes only the white space between elements and the comment
    Allowed difference
    exact
  3. Case 3

    Inputs
    XML <p>Hello <b>world</b>, again</p>Output prettyIndent 2Comments keep
    Expected, and what Toolmoz gave
    text expected <p>Hello <b>world</b>, again</p> , Toolmoz <p>Hello <b>world</b>, again</p> Elements expected 2, Toolmoz 2
    Where the expected answer comes from
    Mixed content is kept exactly as written because the spaces around the b element are significant text
    Allowed difference
    exact
  4. Case 4

    Inputs
    XML <?xml version="1.0" encoding="UTF-8"?><root><item id="1"/><item id="2"/></root>Output prettyIndent 4Comments keep
    Expected, and what Toolmoz gave
    text expected <?xml version="1.0" encoding="UTF-8"?> <root> <item id="1"/> <item id="2"/> </root> , Toolmoz <?xml version="1.0" encoding="UTF-8"?> <root> <item id="1"/> <item id="2"/> </root> Elements expected 3, Toolmoz 3Attributes expected 2, Toolmoz 2
    Where the expected answer comes from
    The declaration stays on the first line and children are indented four spaces
    Allowed difference
    exact

What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

XML
<?xml version="1.0" encoding="UTF-8"?><catalog><book id="b1"><title>Dune</title><price currency="GBP">7.99</price></book><!-- more soon --><book id="b2"><title>Emma</title></book></catalog>
Output
Pretty-print
Indent
2 spaces
Comments
Keep

Example result

Well-formed
Yes
Root element
catalog
Elements
6
Attributes
3
Comments
1
Maximum nesting depth
3
Characters in
189
Characters out
222

Checked against the XML 1.0 well-formedness rules: matching tags, one root, quoted unique attributes, legal characters and only the five predefined entities. It does not validate against a schema or DTD, does not resolve namespace prefixes, and refuses DOCTYPE internal subsets. Formatting re-indents white space between elements only; any element that contains text keeps its content exactly as written.