Skip to content
TypeParser
All tools

XML Formatter

Format, minify, and validate XML.

beats xmlformatter.org edge: DOMParser well-formedness check pre-format
input.xml
output
mode indent
paste XML
Guide

About XML Formatter

Pretty-print, minify, and validate XML in your browser. We run a DOMParser well-formedness check before formatting so you see a precise parse error rather than garbled output. Handles namespaces, CDATA sections, processing instructions, and comments cleanly. Pick indent width — 2, 4, or tab.

What XML formatting touches

XML’s well-formedness rules are stricter than HTML’s. Every tag must close, attributes must be quoted, ampersands must be escaped. A formatter has to honor these rules — but more importantly, it has to refuse output if the input is not well-formed. Garbage in, error out, never garbage in, garbage out.

We use the browser’s built-in DOMParser to validate. If it parses, we format from the parsed tree. If it does not, you see the exact line and message before any formatting attempt.

Common XML you actually format

  • RSS / Atom feeds — debugging a feed reader
  • Sitemaps — verifying a generator’s output
  • SVG — inspecting a designer’s export
  • SOAP envelopes — reading a legacy API response
  • POM (Maven) / Gradle — diffing build configs
  • Android resourcesstrings.xml, colors.xml
  • OPML — exporting / importing podcast subscriptions
  • WSDL / XSD — comprehending vintage SOAP services

The format dropped from “default” to “specialized” over the past decade, but the volume of XML in the wild is enormous and growing slowly.

Common workflows

Debug a malformed feed. Paste the feed XML, see the precise parse error, fix the source.

Compare two XML configs. Format both, drop into the Diff Checker. Whitespace differences vanish; structural drift surfaces.

Audit an SVG export. Format makes the structure readable. Then run SVG Optimizer to strip the editor metadata.

Inspect a SOAP envelope. Most SOAP responses arrive flattened. Format, find the actual payload, ignore the envelope ceremony.

Why a separate tool from HTML

HTML’s parser is forgiving (quirks mode, error recovery, implied tags). XML’s parser is not. Using an HTML parser on XML gives wrong results — implicit tags get added, void elements behave differently, attributes lose their case. The XML-specific tool runs the right parser by default and tells you immediately when input is invalid.

Frequently asked questions

Why does my XML show "no element found"?
DOMParser is strict — your XML probably has an unclosed tag, mismatched quotes, or a stray ampersand. The error message points at the line; check the character before that.
Are CDATA sections preserved?
Yes. <![CDATA[...]]> contents pass through byte-identical. Useful for embedded HTML or SQL.
How does it handle namespaces?
Namespace declarations and prefixed tag names round-trip cleanly. Default namespaces stay on the root or wherever they were declared.
Is XML still relevant?
Less than it was, but RSS, Atom, OPML, sitemaps, SVG, SOAP, OOXML (Word/Excel), Android resources, Maven, Gradle, and many config formats are still XML. The format outlasted its hype cycle.
Can I format SVG with this?
Yes — SVG is XML. For aggressive optimization (strip metadata, collapse paths, remove unused namespaces), use the dedicated SVG Optimizer.
What is XPath in this context?
XPath is for querying XML, like JSONPath for JSON. This formatter shapes the tree but does not query — for query support, look for a dedicated XPath playground.

Related tools

Last updated: 2025-01-15