piapia123
en

XML Formatter & Minifier

Formatting

Everything runs locally in your browser — nothing is uploaded

Input
Output

Re-indent XML one level per element, with comments, CDATA, processing instructions and the DOCTYPE each on their own line. Runs of whitespace inside tags collapse to a single space, while whitespace inside attribute values is preserved exactly, because the two spaces in class="a b" are meaningful. Minify mode drops every bit of whitespace between tags along with the comments. CDATA sections are character data, so they are carried through untouched rather than being re-parsed for tags.

Features

  • Indent by tag level with 2-space, 4-space or tab indentation
  • Collapse whitespace runs inside tags while leaving attribute values exactly as written
  • A > inside an attribute value does not end the tag, so tags are never cut in half
  • Comments, CDATA, the XML declaration and the DOCTYPE each get their own line
  • DOCTYPE internal subsets and entity declarations are not truncated at the first >
  • CDATA content is preserved verbatim and never participates in indentation
  • Minify mode removes the whitespace between tags and the comments
  • No syntax validation: unclosed tags and unbalanced quotes are indented as best they can rather than rejected

How to use

  1. Paste your XML into the input box
  2. Pick the mode and indentation
  3. Press Ctrl/⌘ + Enter or click Run
  4. Click Copy to take the result

FAQ

Why is the content after <br> indented oddly?
XML has no concept of an element that may omit its closing tag, so <br> is treated as an opening tag that never closes. If you are working with HTML, use the HTML formatter instead, which knows the HTML void elements.
Are comments removed?
Format mode keeps them. Minify mode deletes them, since comments have no effect on parsed XML and dropping them makes the output smaller.
What happens with unclosed tags?
Nothing is thrown; the formatter indents as far as the structure allows. Fix the structure before trusting the layout, because tidy output does not mean correct markup.
Is my XML uploaded anywhere?
No. Everything runs in your browser memory, the page makes no network requests, and it works offline.

Related tools