Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

XML formatter & validator

Format, minify and check XML: find the exact line and column of any mistake, explore it as a tree and test XPath expressions.

Tree

Format or check some XML to see its tree.

XPath tester

    How to use

    1. Paste XML into the box, open a file (XML, SVG, RSS, KML, GPX, XSLT and other XML files), or press Sample.
    2. Press Format for tidy indented XML or Minify for the smallest copy. Check only just tells you whether the file is well-formed.
    3. If there is a mistake you get the line, the column, a plain-English reason and a pointer under the spot. Show in the box jumps there.
    4. Copy or save the result, explore the tree, or type an XPath expression and press Run to see which nodes it picks.

    Keyboard

    Ctrl + EnterIn the XML box: format
    EnterIn the XPath box: run the expression
    TabMove between boxes and buttons

    Tips

    • Formatting only changes the spaces and line breaks between elements. Text in elements that mix words and tags (such as <p>A <b>bold</b> word</p>), CDATA sections and anything inside xml:space="preserve" stay exactly as they were.
    • Common mistakes: a bare & (write &amp;), a < in text (write &lt;), a missing closing tag, attribute values without quotes, and two root elements.
    • XPath 1.0 cannot reach elements in a default namespace without a prefix. When the root has one, use the prefix d:, for example //d:item.
    • Handy XPath: //title (all titles), //book[@lang='en'] (by attribute), count(//book) (a number), //book[last()] (the last one).

    About the checker

    The checker follows the well-formedness rules of the XML 1.0 standard: matching tags, quoted attribute values, no duplicate attributes, valid names and characters, known entities, one root element, a correct XML declaration and declared namespace prefixes. It stops at the first problem, as XML readers do. Your browser’s own XML engine runs as a second opinion, and the XPath tester uses it too.

    It does not check a file against a DTD or an XSD schema, so a well-formed file can still be the wrong shape for the program that reads it. The tests compare the checker with Python’s expat XML reader on good and broken files, and check that formatting never changes the content.

    Nothing is stored or sent.

    See you tomorrow!

    A fresh daily puzzle every morning, and new tools added every month.

    Browse every product