Free XML Formatter & Validator
Pretty-print and validate XML using your browser's native DOM parser. Includes minified output for production use.
Drop a file here, or click to browse
XML · processed on your device
or press Ctrl+V to paste from your clipboard
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.
- 1DOMParser validates structureYour 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.
- 2Custom serializer rebuilds the treeA 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.
- 3Structural statistics are countedDuring 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.
- 4Optional JSON conversionA 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
CSS Beautifier
Pretty-print minified CSS with consistent indentation, or minify it. Optional alphabetical property sorting for predictable diffs.
HTML Beautifier & Minifier
Pretty-print or minify HTML with proper nesting indentation. Preserves content inside <pre>, <script>, <style> blocks.
SQL Formatter & Beautifier
Pretty-print SQL queries with proper indentation, configurable keyword case, and line breaks on major clauses. Works with any SQL dialect.