XML Formatter

Pretty-print XML with clean, consistent indentation. Self-closing tags and declarations are preserved, and simple text-only elements stay on one line. Instant and in-browser.

Formatted XML

Readable, indented XML

The formatter re-indents your XML based on how the tags nest, placing each element on its own line so the document structure is clear at a glance. Elements that wrap a single text value (like <title>toolcan</title>) stay on one line, while the XML declaration and self-closing tags such as <item/> are preserved exactly.

Formatting happens in your browser, nothing is uploaded.

What this does

An XML formatter re-indents XML based on tag nesting, putting each element on its own line so the structure is clear.

How to use it

  1. Paste your XML.
  2. Format it.
  3. Read the indented output.
  4. Copy the result.

How it works

Each element is placed on its own line and indented by its depth, while the XML declaration, comments, CDATA sections and self-closing tags are preserved exactly. Only whitespace between elements is changed: an element that contains text (including mixed content like <p>Hello <b>world</b></p>) or sets xml:space="preserve" is copied exactly as written.

Example

A flat <root><item>1</item></root> becomes a nested, indented tree.

Last updated .

Frequently asked questions

What does the formatter do?

It re-indents your XML based on tag nesting, putting each element on its own line so the structure is clear. Elements that contain text are kept exactly as written, spaces and all, so no character data changes.

Are declarations and self-closing tags kept?

Yes. The XML declaration (<?xml …?>) and self-closing tags such as <item/> are preserved exactly.

Is my XML private?

Yes. Formatting happens locally in your browser; nothing is uploaded.