XML Formatter & Minifier
Paste raw XML, confirm it parses, and switch between an indented view for reading and a compact single-line version for pasting into configs or payloads.
XML is still everywhere: sitemaps, RSS and Atom feeds, SVG graphics, Android layouts, Maven build files, SOAP services and a long list of enterprise exports. Machines read it happily no matter how it is laid out, but people do not. A file that arrives as one unbroken line of angle brackets is almost impossible to review, and a single missing closing tag can hide in it for hours. This tool gives you two quick views of the same document: an indented one for reading and a compressed one for transport.
What the tool does when you press each button
The page offers one text area labelled XML Input and two buttons. Format XML first hands your text to the browser's own XML parser. If the parser reports an error, you get an "Invalid XML" message and nothing is formatted, which makes the button a handy well-formedness check as a side effect. If the document parses, the tool re-prints it with two spaces of indentation per nesting level, one tag per line, and shows the result underneath with a copy option.
Minify XML works differently. It does not parse anything. It removes whitespace that sits between a closing bracket and the next opening bracket and squeezes every other run of whitespace into a single space. The output is a compact string that is equivalent for most structural purposes and much shorter to paste into a request body, a command line or a configuration field.
How to use it step by step
- Copy the XML from your editor, API response or export file. Include the XML declaration (
<?xml version="1.0"?>) if there is one. - Paste it into the XML Input box. The box uses a monospaced font so tag alignment is easy to see.
- Click Format XML to validate and indent, or Minify XML to compress.
- Read the result panel. Use the copy control to move it back into your project.
- If you see "Invalid XML", fix the problem in the source and try again. The checklist further down lists the usual causes.
Typical situations where it saves time
- Reviewing a sitemap. A generated
sitemap.xmlis often one long line. Formatting it lets you scan the<loc>entries and spot a stray staging URL before you submit the file to a search engine. - Debugging an API response. SOAP and legacy REST endpoints return XML with no indentation. Pasting it here shows quickly whether the element you expect is nested where you think it is.
- Preparing a payload. Some systems accept XML in a single-line field. Minifying removes the newlines that would otherwise break the field.
- Checking hand-edited configuration. After editing a Maven
pom.xmlor an Android resource file by hand, a quick parse catches an unclosed tag before the build tool does. - Teaching and documentation. Indented samples are far easier to explain in tutorials than a raw dump.
The common reasons XML fails to parse
| Problem | Example | Fix |
|---|---|---|
| Unclosed or mismatched tag | <a><b>text</a> | Close tags in the reverse order they were opened. |
| Unescaped ampersand | Tom & Jerry written with a bare ampersand | Write & inside text and attribute values. |
| Unquoted attribute | <item id=5> | Quote every attribute value: id="5". |
| More than one root element | Two sibling top-level elements | Wrap everything in a single root element. |
| Text before the declaration | A blank line or byte-order junk before <?xml | The declaration must be the very first thing in the file. |
| Case mismatch | <Name>x</name> | XML is case-sensitive, so tag names must match exactly. |
Know the limits before you rely on the output
Please read: the indenter is a lightweight, line-based routine, not a full serializer. It works well for documents where elements either contain other elements or are self-closing. When an element holds only text on one line, such as <title>Dune</title>, the nesting depth it tracks can drift, so sibling elements further down may appear indented deeper than they should be, and the last closing tag can pick up an extra bracket. The tag order and content are unchanged, only the visual indentation is affected. Treat the formatted output as a reading aid and compare it with your source before committing it anywhere that matters.
Other things the tool does not do: it does not validate against a schema (XSD or DTD), it does not reorder attributes, and it does not preserve whitespace-sensitive content in the minified view because every run of whitespace becomes a single space. If your XML contains preformatted text, CDATA blocks with meaningful line breaks, or xml:space="preserve" regions, do not minify it with this tool.
Privacy and where the work happens
Both buttons run in JavaScript inside your own browser tab. The page does not send your text anywhere to format it, and there is no account or upload step. That said, you should still avoid pasting credentials, private keys or personal data into any web page you do not control, and clear the box when you are finished on a shared computer.
Frequently asked questions
Does a successful format mean my XML is valid?
It means the document is well-formed, which is the basic grammar of XML: balanced tags, quoted attributes, a single root. It does not mean the content follows a specific schema. A well-formed sitemap can still contain the wrong element names, and this tool will not notice.
Why did Minify accept XML that Format rejected?
Minify only rearranges whitespace and never parses the document, so it will happily compress broken markup. Run Format first if you need to know the input is sound.
Can I format very large files?
The text has to fit in a browser text box, so files of a few megabytes can feel slow or freeze the tab. For very large exports, a command-line tool such as xmllint or an editor plug-in is a better choice.
Will it keep my XML comments?
Comments are part of the text that is re-printed, so they stay in the output. Minify also keeps them, because it only touches whitespace.
Is the output safe to paste straight into production?
Diff it against your original first, especially after Format, because of the indentation caveat above. Minified output is the safer of the two when you only need a compact copy.