XML Formatter
Format and validate any XML document: SOAP envelopes, RSS feeds, SVG files, Office Open XML. Indent nested elements, highlight syntax errors with line and column, and minify the result for transport. Built on the browser DOMParser for full XML 1.0 compliance.
How to use
- 1
Paste XML
Drop your XML document into the input editor.
- 2
Choose indentation
Pick 2 or 4 spaces, or tabs, and toggle attribute sorting.
- 3
Beautify or minify
Click Beautify for readable output or Minify for the smallest possible result.
Technical details
XML (Extensible Markup Language) is a strict text format for hierarchical data, defined by W3C and still ubiquitous in enterprise integration, document formats (DOCX, ODT, SVG) and configuration files. Unlike HTML, XML requires every tag to be closed, every attribute to be quoted and special characters to be escaped — failing on a single missing slash.
The formatter parses input with the browser DOMParser, which throws on the first error and reports the line and column. The result is a fully parsed DOM tree, which is then serialised with configurable indentation (2 or 4 spaces or tabs) and optional sorted attribute order.
XML namespaces are preserved exactly: prefixes, declarations and default namespaces all round-trip without modification. CDATA sections and processing instructions (`<?xml-stylesheet?>`) are also kept intact, which makes the formatter safe to use on SVG and RSS without breaking embedded scripts or styles.
For minification, the formatter strips all whitespace between elements except inside `xml:space="preserve"` blocks, which dramatically shrinks SOAP messages and document formats while remaining semantically identical.
Frequently asked questions
Does it validate against a DTD or XSD?
Are CDATA sections preserved?
Will namespaces be kept intact?
How large a document can it format?
Is anything uploaded?
This tool was tested and calibrated by our engineering team. All processing happens locally in your browser — your files and data never leave your device.