XML Formatter

Pretty-print XML with namespace, CDATA, and comment support.

Input336 chars
Output
paste XML and click Format

Related Tools

Documentation

What is XML Formatter?

A tool that re-indents raw or minified XML for readability, using the browser's built-in XML parser rather than a third-party library.

How it works

Input is parsed with DOMParser, then walked recursively to rebuild indented output — self-closing empty elements, single-line text-only elements, comments, and CDATA are each handled explicitly.

Common errors

Unclosed tags, mismatched closing tags, and unescaped ampersands (use & for a literal &) are the most frequent causes of a parse failure.

Frequently Asked Questions

What does the XML Formatter do?

It parses XML with the browser's native DOMParser, then pretty-prints it with consistent indentation, preserving comments, CDATA sections, and namespaced attributes.

Does it support XML namespaces?

Yes — namespace prefixes (like dev:features) and their declarations are preserved exactly as written.

What happens to comments and CDATA?

Both are kept in place rather than stripped, since removing them can change intent (CDATA often protects literal markup characters from being escaped).

Why does it say "Malformed XML"?

The DOMParser reports a parser error for issues like unclosed tags, mismatched tags, or invalid characters. Unlike JSON, there's no line/column from the native parser — check for the most recently opened tag first.

What does Minify do?

It removes whitespace between tags, producing the smallest valid representation without changing the document structure.

Is my XML uploaded anywhere?

No — parsing and formatting run entirely in your browser.