XML Formatter
Reformat XML with proper nested indentation based on tag depth — a lightweight tag-based indenter, not a full XML parser.
- 1Paste your XML
- 2Click Convert
- 3Copy the indented output
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.xmlor .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.
Related Tools
JSON Formatter
Pretty-print JSON with real 2-space indentation using the browser's native JSON parser — shows the exact parse error if your JSON is invalid.
JSON Minifier
Compress JSON to its smallest valid form by removing all whitespace, using the native JSON parser.
HTML Formatter
Reformat HTML with proper nested indentation based on tag depth — a lightweight tag-based indenter, not a full HTML parser.