What Is the XML Formatter?
Format and prettify XML with your choice of 2-space, 4-space or tab indentation, check it for well-formedness with line and column error messages, or minify it. Syntax highlighting makes the structure easy to scan.
Why Use This Tool?
Raw XML from APIs, config files, or data exports is often minified or poorly formatted. This tool adds proper indentation and structure so you can read and debug XML documents quickly.
How to Use This XML Formatter
- Paste your XML — Enter raw, minified, or messy XML into the input area.
- Click Format — The tool parses the XML tree and outputs it with proper indentation, line breaks, and consistent attribute formatting.
- Set indentation — Choose 2-space, 4-space, or tab indentation to match your project conventions.
- Copy the result — Click Copy to grab the formatted XML for your configuration files, SOAP responses, or data documents.
Worked example: does formatting change the data?
A formatter is only safe if it changes whitespace and nothing else. On October 12, 2026 we ran the tool's own format and minify code in Chromium on three files:
- this site's sitemap.xml (782 URLs);
- its RSS feed;
- a small test document with mixed content (
Hello <b>bold</b> world), anxml:space="preserve"block, a namespaced element, an escaped&in an attribute, CDATA and a comment.
We then checked every output with xmllint (libxml2): first for well-formedness, then by comparing Canonical XML (C14N) of the original and the output after setting aside whitespace-only text between tags.
| File | Original | Formatted (2-space) | Minified | Same data (C14N)? |
|---|---|---|---|---|
| sitemap.xml | 133,760 B | 148,485 B | 128,640 B (−3.8%) | Yes, both outputs |
| RSS feed | 231,669 B | 233,259 B | 212,618 B (−8.2%) | Yes, both outputs |
| Mixed-content test | 223 B | 222 B | 221 B | Yes, byte-identical C14N even with whitespace counted |
All six outputs were well-formed, and none changed an element, attribute, text value, CDATA section or comment. The mixed-content test shows the important part. The paragraph with inline <b> and the xml:space="preserve" block were left exactly as written, because re-indenting inside them would add spaces to the actual text.
Minifying saves less than you might expect: 3.8% on the sitemap and 8.2% on the feed. After gzip, which servers normally apply to XML, the difference shrinks further, from 8,825 to 8,557 bytes for the sitemap (−3.0%). Minify when a system has a hard size cap. Otherwise the readable version costs almost nothing in transfer.
Sources
Checked on .
Common Use Cases
Inspecting a SOAP response or a sitemap before deciding whether something's wrong with the upstream service or with your parsing. Auditing an sitemap.xml or RSS feed for malformed entities and missing namespaces before pushing it live (and before search engines or feed readers complain about well-formedness errors that block ingestion entirely).
Pretty-printing minified XML from a config-management export so you can review the diff against the previous version. Validating that an XSLT-produced document closes every tag and quotes every attribute correctly before downstream consumers parse it. Reformatting AndroidManifest.xml, pom.xml, or similar build-system files after a tooling merge has flattened the whitespace. Inspecting SVG source for rogue inline styles or stray namespaces before optimization.
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools