XML Formatter & Beautifier
Paste messy or minified XML to format, validate, minify, or download — with syntax highlighting
Paste minified or messy XML, pick your indent size, and get clean structured output with syntax highlighting in one click. The formatter also validates on the fly — missing closing tags, unquoted attributes, broken nesting — so you catch errors before they cause problems downstream. And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter reads your XML string, builds a DOM tree from it, then serializes it back out with proper indentation at each nesting level. If the XML is malformed — unclosed tags, missing quotes on attributes, stray characters — the parser catches it and shows you exactly where the problem is. You can also minify in the other direction: strip all whitespace down to a single compact line for production use.
Examples
Formatting a minified API response
You grabbed a SOAP response from the network tab and it's one giant line.
<catalog><book id="1"><title>XML Dev Guide</title><price>44.95</price></book><book id="2"><title>Midnight Rain</title><price>5.95</price></book></catalog>
<catalog>
<book id="1">
<title>XML Dev Guide</title>
<price>44.95</price>
</book>
<book id="2">
<title>Midnight Rain</title>
<price>5.95</price>
</book>
</catalog>
Cleaning up a messy sitemap.xml
Sitemaps exported from CMS plugins are often inconsistently indented. Some lines have tabs, some have spaces, some have neither.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-03-01</lastmod>
</url>
<url><loc>https://example.com/about</loc></url>
</urlset>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-03-01</lastmod>
</url>
<url>
<loc>https://example.com/about</loc>
</url>
</urlset>
Minifying XML for a config deployment
You need to embed XML inside a JSON string or ship a smaller payload. Stripping whitespace shaves off 30-40% of file size on deeply nested configs.
<config>
<database>
<host>db.prod.internal</host>
<port>5432</port>
</database>
</config>
<config><database><host>db.prod.internal</host><port>5432</port></database></config>
Who Uses This
Debugging SOAP APIs, reading Spring configs, or inspecting Maven POM files that got mangled in a merge.
Comparing XML test fixtures side by side after formatting both to the same indent style.
Learning XML structure for class assignments — seeing proper nesting makes the syntax click faster.
Quickly reading Kubernetes or CI/CD pipeline configs that ship as single-line XML blobs.
Common Mistakes
The formatter will flag it, but people sometimes ignore the error and wonder why the output looks off. Read the validation message — it tells you exactly which tag is unclosed and roughly where.
If you paste a log file that has XML fragments surrounded by plain text, the parser will choke. Extract just the XML portion first. The tool expects a complete, standalone XML document or fragment.
Writing <item count=5> instead of <item count="5"> is valid in HTML but not in XML. The formatter will reject it. Add quotes around every attribute value — double or single, both work.
Technical Details
- Processing: 100% client-side — your XML never leaves the browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Input Size: Limited only by your browser's memory (tested up to 10 MB)
- Indent Options: 2 spaces, 4 spaces, or tab characters
Frequently Asked Questions
What is the difference between XML formatting and XML validation?
Formatting fixes the visual layout — adding indentation and line breaks so you can actually read the structure. Validation checks whether the XML follows the rules: matching open/close tags, quoted attributes, proper nesting. This tool does both at once. If your XML is broken, it won't just blindly indent it — it'll tell you what's wrong first.
Can I format XML with namespaces?
Yes. Namespaced elements like <soap:Envelope> or <xs:schema> format exactly the same way as regular elements. The formatter preserves all namespace prefixes and declarations. It doesn't strip or modify them.
Does formatting change the meaning of my XML?
No. Adding or removing whitespace between tags doesn't change the data. The element names, attributes, and text content stay identical. One edge case: if you have a text node where whitespace matters (like inside a <pre>-style element), formatting could alter it. For 99% of use cases though, the formatted output is functionally identical to the original.
How do I minify XML instead of formatting it?
Click the Minify button instead of Format. It strips all unnecessary whitespace — line breaks, indentation, trailing spaces — and gives you a single compact line. Useful when you're embedding XML in a JSON payload or trying to reduce file size for transfer.
Is my XML data safe when using this tool?
Completely. The tool runs entirely in JavaScript inside your browser tab. Nothing gets sent to any server — not even ours. You can disconnect from the internet and it still works. Once you close or refresh the page, the data is gone from memory.