Beautify XML with proper indentation, or minify it to a single line. Comments, CDATA and processing instructions are preserved.
How to use the XML Formatter
Paste your XML into the input box.
Choose Beautify to indent it or Minify to compress it.
Pick the indent size, then copy the result.
This is an XML formatter that beautifies a document with proper, depth-based indentation, or minifies it to a single line. It preserves comments, CDATA sections, processing instructions and the XML declaration.
Formatting runs entirely in your browser, so your data never leaves your device, which makes it safe even for XML that contains sensitive values.
XML is verbose and deeply nested. Indenting each element by its depth and putting tags on their own lines turns a wall of angle brackets into a structure you can actually follow.
It is useful across the many places XML still lives: SOAP responses, RSS feeds, build and config files, and document formats, where a quick reformat makes debugging far easier.
Beautifying keeps a single text child inline with its tags, so simple values stay compact, while the declaration, comments and CDATA are kept exactly as they were rather than being reflowed or dropped.
Minifying removes comments and the whitespace used only for indentation between tags. Text content and CDATA are kept exactly, so it is safe unless your document relies on significant whitespace in mixed content.
The tool reformats for readability and does not validate against a schema. Clean layout does not mean the document matches any DTD or XSD you expect.
Frequently asked questions
It indents each element by its nesting depth and puts tags on their own lines, while keeping a single text child inline. Comments, CDATA and the XML declaration are preserved.
It removes comments and the whitespace used only for indentation between tags. Text content and CDATA sections are kept exactly, so it is safe unless your document relies on significant whitespace in mixed content.
No. Formatting runs entirely in your browser, so your data never leaves your device. That makes it safe even for XML that contains sensitive values.
A CDATA section holds text that should not be parsed as markup, so characters like < and & can appear literally. The formatter keeps CDATA content exactly as it is.
No. It reformats the document for readability and does not check it against a DTD or schema, so it will lay out XML even if it is not valid.
Embed this tool
Add this tool to your own website. Copy the snippet below; it stays up to date automatically.
<iframe src="https://monu.tools/embed/en/xml-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>Related tools
Beautify CSS with clean indentation, or minify it to shrink file size. Handles media queries, calc() and license comments.
Beautify HTML with block-aware indentation, or minify it. The contents of pre, textarea, script and style are preserved.
Beautify and prettify JavaScript with consistent indentation and spacing. Runs entirely in your browser.
Convert CSV to an Excel .xlsx file and Excel back to CSV, entirely in your browser. Works in both directions.