Text UtilitiesText FormattersFree Tool

XML Formatter

Reformat XML with proper nested indentation based on tag depth — a lightweight tag-based indenter, not a full XML parser.

How to Use XML Formatter
  1. 1Paste your XML
  2. 2Click Convert
  3. 3Copy the indented output
About XML Formatter

What this XML formatter does

The formatter re-indents XML so that its structure is visible. It puts each tag on its own line and indents child elements two spaces deeper than their parent. Closing tags move back out one level, self-closing tags such as <item /> and processing instructions such as <?xml version="1.0"?> do not add a level, and an element that holds only text (<name>Ana</name>) stays on a single line.

Example

Input: <order id="7"><customer>Ana</customer><items><item sku="A1"/><item sku="B2"/></items></order>

The output shows order at the left margin, customer and items indented one level, and the two item elements indented another level under items. The data is unchanged; only whitespace is added.

Where formatted XML is useful

  • SOAP and API responses that arrive as one long line.
  • Sitemaps, RSS feeds and Android resource files you need to read or check by eye.
  • Configuration files such as Maven pom.xml or .NET config, where nesting mistakes cause hard-to-find errors.
  • Diffing two XML documents, which is only practical when both use the same indentation.

Limits you should know about

  • It is a text-based formatter, not a parser. It does not check that the XML is well-formed, so mismatched or unclosed tags are indented as written rather than reported. Use a validator when correctness matters.
  • Mixed content may not look ideal. Text that is interleaved with tags inside a paragraph-like element can be laid out differently from how an XML-aware editor would show it.
  • Comments and CDATA are placed on their own lines but are not specially re-flowed.
  • Whitespace can be meaningful. In a few XML dialects, whitespace inside text is significant. Formatting is safe for most configuration and data files but think twice before reformatting documents whose text must be preserved exactly.

Formatting versus minifying

Indented XML is for people; minified XML is smaller for storage or transfer. For the compact form, use the XML minifier, and for web markup try the HTML formatter. If your data is JSON rather than XML, use the JSON formatter.

Privacy

Everything runs in your browser. Still, remove credentials or personal data from configuration files before sharing formatted output.

Frequently Asked Questions

It splits your XML at every '><' boundary onto its own line, then increases indent depth on opening tags and decreases it on closing tags.

No — this tool only reformats indentation; it doesn't check for unclosed tags or syntax errors. Use the XML Validator tool in Developer Tools for a real well-formedness check.

Self-closing tags (ending in />) don't increase indent depth, which is handled correctly. Complex cases like CDATA sections may not indent perfectly, since this is a lightweight tag-splitter, not a full XML parser.

No — formatting happens entirely in your browser.

Related Tools

Related Articles

More from Text Utilities