DukoTools

XML Formatter

New

Format, minify, and validate XML with interactive collapsible tree view and XPath query support.

Free Forever
No Signup Required
No Files Stored

Embed this tool

Add this tool to your website or blog with a single iframe snippet.

<iframe src="https://dukotools.com/tools/xml-formatter?embed=1" width="100%" height="600" frameborder="0" allow="clipboard-write" loading="lazy" title="xml-formatter tool"></iframe>

About XML Formatter

XML Formatter is a professional-grade XML development tool combining formatting, minification, validation, and interactive tree visualisation in a single page. Paste raw XML and click Format to get cleanly indented XML with 2-space indentation. Click Minify to remove all whitespace for compact wire transfer. Live validation with 300ms debounce means you see errors highlighted as you type without any button click. The tree view is the differentiating feature: toggle to an interactive collapsible tree showing every element, its attributes, and text content. The XPath query input below the tree lets you enter any XPath expression and see matching nodes highlighted in the tree and listed in a results panel.

Key Features

  • Format and Minify

    One-click pretty-print with 2-space indentation or minification removing all whitespace.

  • Well-Formedness Validation

    Validates XML with real-time error messages showing line number and error description.

  • Interactive Tree View

    Collapsible element tree showing tag names, attributes, and text content per node.

  • XPath Query Input

    Run XPath expressions and see matching nodes highlighted in the tree and listed in results.

  • Syntax Highlighted Output

    Formatted XML output displayed with syntax colouring.

  • Element and Character Count

    Shows total element count and character count as document statistics.

How to Use

  1. 1

    Paste XML

    Paste raw or minified XML into the input textarea.

  2. 2

    Format or Minify

    Click Format for pretty-printing or Minify for compact output.

  3. 3

    Validate

    Click Validate or check the live error indicator for well-formedness problems.

  4. 4

    Explore the tree

    Toggle tree view to browse the document structure with collapsible nodes.

  5. 5

    Run XPath

    Enter an XPath expression in the query box to find and highlight specific nodes.

Real-World Use Cases

API Response Debugging

A developer receives a minified XML response from a SOAP API and uses the formatter to indent and browse the structure before writing a parser.

XPath Development

A developer writing an XSLT transformation uses the XPath query input to test expressions against sample XML before embedding them in the stylesheet.

Config File Review

A DevOps engineer uses the tree view to browse a complex Maven pom.xml and verify dependency declarations without counting indentation levels.

Frequently Asked Questions

Related Free Tools