Skip to main content

Free XML Formatter & Validator

Pretty-print and validate XML using your browser's native DOM parser. Includes minified output for production use.

Works offline once loaded

Drop a file here, or click to browse

XML · processed on your device

or press Ctrl+V to paste from your clipboard

Browse files
Output will appear here…

Common uses

  • Format RSS / Atom FeedsInspect and pretty-print RSS or Atom feed XML to verify structure before publishing.
  • Format SOAP API Requests and ResponsesSOAP envelopes are notoriously hard to read on one line. Format them to debug API calls.
  • Format and Validate Sitemap.xmlCheck sitemap.xml for SEO — see all URLs and verify the structure is valid before submitting to Google.
  • Inspect Office Document XMLModern .docx, .xlsx, .pptx files are ZIP archives of XML. Inspect the internal XML for debugging.
  • Inspect XML Configuration FilesSpring, .NET, Tomcat, Maven, Ant — many ecosystems use XML config. Format for review.

How It Works

This tool parses and reformats XML entirely in your browser using the built-in DOMParser API — the same XML engine that browsers use to handle SVG and XHTML. No library is loaded; the pretty-printer, minifier, and JSON converter are all hand-written in this tool.

  1. 1
    DOMParser validates structure
    Your XML is fed to the browser's native DOMParser with MIME type application/xml. If the document is not well-formed — an unclosed tag, a missing root element, mismatched quotes — DOMParser produces a parsererror node and the tool surfaces the browser's own error message rather than silently ignoring the problem.
  2. 2
    Custom serializer rebuilds the tree
    A hand-written recursive walker traverses every node in the parsed DOM — elements, text nodes, CDATA sections, comments, and processing instructions — and re-serializes them with your chosen indent width (1, 2, or 4 spaces). Minified output reuses the same walker with an empty pad string, so whitespace-only text nodes are stripped without touching text content inside elements.
  3. 3
    Structural statistics are counted
    During the formatted serialization pass the walker counts every element and attribute in the document and reports totals alongside before/after character sizes, giving you a quick structural overview of the XML without any extra parse step.
  4. 4
    Optional JSON conversion
    A second recursive function converts the parsed DOM to a JSON object: element attributes become keys prefixed with @, repeated sibling elements become arrays, and lone text children become plain string values. The result is serialized with JSON.stringify for download or copy.

Related Tools

Frequently Asked Questions