Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

XML Formatter & Beautifier

Paste messy or minified XML to format, validate, minify, or download — with syntax highlighting

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

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

Paste Raw XML
➔
Parse & Indent
➔
Formatted Output

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.

INPUT
<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>
OUTPUT
<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.

INPUT
<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>
OUTPUT
<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.

INPUT
<config> <database> <host>db.prod.internal</host> <port>5432</port> </database> </config>
OUTPUT
<config><database><host>db.prod.internal</host><port>5432</port></database></config>

Who Uses This

👨‍💻 Backend Developers

Debugging SOAP APIs, reading Spring configs, or inspecting Maven POM files that got mangled in a merge.

📊 QA Engineers

Comparing XML test fixtures side by side after formatting both to the same indent style.

🎓 Students

Learning XML structure for class assignments — seeing proper nesting makes the syntax click faster.

⚙️ DevOps

Quickly reading Kubernetes or CI/CD pipeline configs that ship as single-line XML blobs.

Common Mistakes

Pasting XML with a missing closing tag

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.

Including non-XML content mixed in

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.

Forgetting to quote attribute values

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

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.

Share: