Free Tools Grid

XML Formatter

Developer Tools

Pretty-print XML documents with proper indentation, preserved attributes, and tidy nesting.

Runs entirely in your browser
Loading tool...

About XML Formatter

The XML Formatter takes any XML — SOAP responses, RSS feeds, Android manifests, SVG sources, configuration files — and rebuilds it with consistent indentation and one element per line. It uses `fast-xml-parser` in preserve-order mode, which means the structure (element order, attribute order, text content) is byte-faithful to the input; only whitespace changes.

This is the tool to reach for when an XML response is one long line, or when nested elements make it hard to spot a malformed tag. Indent depth is configurable (2 spaces, 4 spaces, or tab), and the formatter handles namespaces, CDATA sections, processing instructions, and empty elements correctly. Everything runs in your browser, so even XML payloads containing internal data stay on your machine.

How to use

  1. 1

    Paste your XML

    Drop the XML document or fragment into the input editor.

  2. 2

    Choose indentation

    Pick 2 spaces, 4 spaces, or Tab from the Indent dropdown.

  3. 3

    Copy or download the output

    Use Copy or Download (.xml) to take the formatted result.

Examples

Pretty-printing a flat XML document

A one-line XML document expands into a readable, indented hierarchy.

Input

<?xml version="1.0"?><books><book id="1"><title>Hyperion</title><author>Dan Simmons</author></book></books>

Output

<?xml version="1.0"?>
<books>
  <book id="1">
    <title>Hyperion</title>
    <author>Dan Simmons</author>
  </book>
</books>

Frequently asked questions

Does it validate the XML?+

Well-formedness is implicitly checked — malformed XML will surface a parse error. For DTD or XSD schema validation, use a dedicated XML validator.

Are namespaces preserved?+

Yes. Namespace prefixes (e.g. `xmlns:soap`) and their qualified usage stay exactly as written.

What about CDATA blocks?+

CDATA sections are preserved verbatim, including any whitespace inside them.

Does it sort attributes or elements?+

No. Attribute and element order are kept exactly as in the input. The formatter only changes whitespace.

Is my XML sent anywhere?+

No — parsing and formatting both happen in your browser.