XML Formatter

Pretty-print messy XML, squeeze it onto one line, or find out exactly where it breaks. Paste XML or open a file such as an RSS feed, SVG or config.

Runs in your browser. Nothing is uploaded Free, no sign-up Works on mobile
Action
Indent

Comments, CDATA sections and attribute quoting are kept as written. Elements that contain text stay on one line, so no text or spacing inside them changes.

How to format XML

  1. Paste XML or open an .xml file.
  2. Choose Format or Minify and the indent.
  3. Fix any error shown with its line and column, then copy or save the result.

Features

  • Format with 2 spaces, 4 spaces or tabs
  • Minify to one line
  • Errors with line and column
  • Keeps comments, CDATA and DOCTYPE
  • Open and save .xml files
  • Works with SVG, RSS, sitemaps and configs

Frequently asked questions

Why does it say my XML is invalid?

Common causes are a closing tag that does not match its opening tag, an unescaped & or < in text, an attribute without quotes, or more than one root element. The message gives the line and column to look at.

Are comments and CDATA kept?

Yes. Comments, CDATA sections, processing instructions and the DOCTYPE stay exactly as written. Tick “Remove comments” to drop comments.

Will formatting change my data?

Elements that contain text are kept on one line with their text untouched, so values and mixed content such as <p>Hello <b>there</b></p> do not change. Only whitespace between tags is adjusted.

Can it handle large files?

Yes. A 5 MB file formats in about a second because nothing is uploaded.

Is my data sent to a server?

No. Everything runs in your browser, so configs, API responses and code never leave your device.

Related tools

All Developer Tools →