Developer Tools

XML Formatter

Validate and format XML or SVG with two-space, four-space or tab indentation.

About this tool

Validate and format XML or SVG with two-space, four-space or tab indentation.

What this tool handles

The tool parses a complete XML document before formatting it. It supports declarations, doctypes, namespaces, comments, CDATA and SVG documents, and reports malformed XML instead of returning a partial result.

Important behavior

Indentation is added only where it is safe. Mixed text content and elements marked with xml:space="preserve" are serialized without reflow so meaningful whitespace is not deliberately changed.

Private browser processing

The selected file and pasted text are processed locally in this browser tab and are not sent to the server.

How to use

Load an XML or SVG file or paste the document, choose two spaces, four spaces or tabs, process it, inspect the preview and download the full formatted XML.

FAQ

Does the formatter validate XML syntax?
Yes. It checks whether the browser can parse the complete document and shows an error when tags, attributes or document structure are invalid.
Are comments and CDATA preserved?
Yes. Formatting keeps XML comments and CDATA sections. It only changes structural indentation where that can be done safely.
Can I format SVG files?
Yes. SVG is XML, so a valid SVG document can be loaded, formatted and downloaded as XML without rendering or modifying the graphic.
Will formatting change text whitespace?
Mixed content and xml:space="preserve" are not re-indented. Even so, test whitespace-sensitive documents in their target system.
Is the document uploaded?
No. XML parsing and formatting run locally in the browser tab and do not require a server upload.