XML formatter
Pretty print or minify XML instantly.
Runs in your browser. Nothing you type is sent anywhere.
- Keeps comments and CDATA
- Pretty print or minify
- Exact error location
How to format XML
- Paste your XML or upload the file.
- Choose pretty print or minify.
- Copy the result or download it.
What formatting changes and what it keeps
| Changes | Keeps exactly | |
|---|---|---|
| Pretty print | Adds indentation and line breaks between tags | Text, attributes, comments, CDATA, entities |
| Minify | Removes indentation and line breaks | Text, attributes, comments, CDATA, entities |
Why minify an XML file
- Config and data files load faster and use less bandwidth once whitespace is gone.
- Some CMS and API exports indent deeply, so minifying can shrink them by 10 to 30 percent.
- A feed served to another system rarely needs to stay human-readable.
Common causes of malformed XML
- An unclosed or mismatched tag.
- A bare & or < inside text that should be written & or <.
- Two elements at the top level with no single shared root.
Where formatting XML helps
- Reviewing a diff of a config file, since consistent indentation makes the real changes stand out.
- Reading a compact XML API response without scrolling sideways through one long line.
- Preparing a file for a code review where reviewers expect readable, indented markup.
XML formatter FAQ
Does formatting change my data?
Only the whitespace between tags changes. Text, attributes, comments, CDATA sections, the DOCTYPE and entities such as & stay exactly as written.
Why does it say my XML is malformed?
Common causes are an unclosed or mismatched tag, or a bare ampersand or less-than sign inside text. The error names the line and column, and Jump to error selects it.
How much smaller does minify make a file?
It removes indentation and line breaks between tags. Heavily indented files often shrink by 10 to 30 percent.
Can I format SVG files?
Yes. SVG is XML, so you can upload an .svg file and pretty print or minify it here.
Does it support DOCTYPE declarations?
Yes. A DOCTYPE is kept exactly as written and put back in place after formatting, since the underlying parser reads it but does not reproduce it on its own.
Can I paste an RSS or Atom feed?
Yes. Both are XML documents, so pretty print and minify work the same as with any other XML.
Does it work on very large XML files?
Yes, though a very large file takes longer to parse and format in the browser than a small config file. There is no fixed size limit.
Can it fix an XML file that is missing a closing tag?
No. Formatting only rearranges whitespace in XML that already parses correctly. Fix an unclosed or mismatched tag in your editor first, then format the result.