XML Beautifier
Beautify XML in your browser. Reformat compact or messy XML into clean, indented code. CDATA-safe, namespace-aware, all-local processing via your browser's native DOMParser.
Messy in, clean out
Same data, structured for human eyes. Beautify expands compact XML into a line-per-element, properly indented document.
<root><item>one</item><item>two</item></root>
<root> <item>one</item> <item>two</item> </root>
What you'll use this for
Anywhere unreadable XML shows up — feeds, config files, SOAP traffic, sitemaps.
RSS / Atom feeds
Pretty-print a feed before publishing or subscribing.
Config files
Reformat pom.xml, web.config, build descriptors.
SOAP envelopes
Tidy a SOAP request before sending.
Sitemaps
Indent sitemap.xml for review.
How to beautify XML
Paste your XML
Drop it into the left editor. Compact, single-line XML works fine.
Pick indent
2 spaces by default. Switch to 4 spaces or tab to match your project style.
Click Beautify
Or leave auto-format on for live updates. Runs locally with DOMParser + XMLSerializer.
Copy or download
Copy to clipboard, save as .xml, or flip the Mode to Minify to compress back.
Frequently asked questions
Yes. CDATA sections, comments, and processing instructions are preserved as-is.
Yes — choose 2 spaces, 4 spaces, or tab.
Yes. No signup, no limits, no ads.
No. Uses your browser's native DOMParser + XMLSerializer.
Yes — xmlns declarations and prefixed elements pass through unchanged.
About this beautifier
XML beautification is a one-pass operation: parse the input with the browser's native DOMParser, serialize it back through XMLSerializer, then walk the token stream to apply consistent indentation. The result is canonical — same structure regardless of whether the input was tightly packed, hand-typed, or pre-indented.
What it does
- Indents at 2 spaces (default), 4 spaces, or tab.
- One element per line for opening, closing, and self-closing tags.
- Namespaces preserved.
xmlnsdeclarations and prefixed elements pass through untouched. - CDATA, comments, PIs kept verbatim — no whitespace inserted inside them.
- Minify mode strips inter-tag whitespace to compact the document.
What it doesn't do
- XSD / DTD validation. Well-formedness only. For schema checks use a dedicated XSD tool.
- Lossy edits. No attribute reordering, no element removal. Round-trips back through any conformant XML parser.
- HTML. XML mode is strict — unclosed tags or unquoted attributes raise a parse error. Use the HTML formatter for HTML.