XML Formatter — Pretty Print & Minify

Format XML online: pretty-print with 2-space, 4-space or tab indentation, or minify to one line. Runs in your browser — nothing is uploaded. No upload — runs 100% in your browser

How to use this tool

  1. Paste or drop your input above.
  2. The tool processes it locally — usually instantly.
  3. Copy the output or download the result.

What an XML formatter actually does

XML does not care about whitespace between tags — a machine reads a minified one-liner exactly the same as a deeply indented tree. Humans do care, though: reviews, diffs and merge conflicts all depend on one element per line with consistent indentation. This tool rewrites only the whitespace between tags: every element goes on its own line, nested content is indented by your chosen unit, and an element whose content is just short text stays on a single line instead of being split across three.

Three things are deliberately left alone. Attributes are kept exactly as you wrote them, on the same line as their tag, quotes untouched. Comments, CDATA blocks and the <?xml ?> declaration are passed through verbatim. And text inside elements only has its runs of whitespace collapsed — words themselves are never re-wrapped or re-ordered.

Pretty-print or minify?

Pretty-print for anything a human will read: configuration files, API responses you are debugging, data files going into review. Minify for the wire: a smaller payload for the same data (parsers ignore inter-tag whitespace anyway, so minifying is lossless for XML semantics). The stats line shows the element count and maximum depth, which is often the fastest way to sanity-check a feed's structure.

Well-formedness feedback

The tool also counts opens and closes while it walks your document. If they do not balance, you get a warning with the stray-close and unclosed counts — that catches the most common hand-editing mistake (a deleted closing tag) before you ship the file. This is a well-formedness check, not validation: it does not verify your document against a DTD or XSD schema.

Frequently Asked Questions

Are my files uploaded to a server?

No. Everything on this page runs inside your browser using JavaScript and WebAssembly. Your file never leaves your device — you can even disconnect from the internet after the page loads and the tool still works.

Does formatting change my XML data?

No. Only whitespace between tags is rewritten, and runs of spaces inside text are collapsed to single spaces. Element names, attributes, order and values all pass through untouched.

Does it validate against a schema?

No — it checks well-formedness (balanced tags) only. XSD/DTA schema validation is a different, heavier job; the balance warning catches the most common structural mistakes.

Why did my one-line element stay on one line?

Elements whose content is short plain text are kept inline — that is the readable convention most formatters use. Longer or nested content is split across lines.

Is there a size limit?

No hard limit; the whole file is parsed in your browser's memory. Files of several megabytes format in a moment on a modern laptop.

Related Tools

Line CounterChinese Word CounterX/Twitter Character CounterYAML to JSONJSON to YAMLCSV to JSONCSV to ExcelExcel to CSVXML to CSVCSV to XMLHTML Entity DecoderCase ConverterKebab Case ConverterJSON DiffDOCX to TXT