ToolLineup

XML Formatter & Beautifier

This XML formatter turns minified or inconsistently indented markup into a clean, readable document. It works on the raw markup rather than parsing to data and rebuilding, which is what lets it preserve comments, CDATA sections, processing instructions and the DOCTYPE — all of which a parse-and-rebuild round trip silently discards. Elements whose only content is text stay on one line, so a record with twenty simple fields stays twenty lines instead of sixty. Indent with two spaces, four spaces or tabs. Everything runs in your browser.

How it works

Re-indents a document without changing what it contains. Comments, CDATA sections, processing instructions and the DOCTYPE are all preserved, because formatting works on the raw markup rather than parsing to data and rebuilding — a round trip that would quietly drop exactly those parts.

An element holding nothing but text stays on one line, so a long list of simple fields does not triple in height.

Everything runs in your browser — nothing you paste is sent to a server.

XML input
Paste XML here…
Formatted XML

How to format XML online

  1. Paste your XML into the input on the left.
  2. The indented result appears on the right, ready to copy or download.
  3. Choose 2 spaces, 4 spaces or tabs to match your project conventions.

What is preserved

Formatting works on the raw markup rather than parsing the document into data and rebuilding it. That distinction matters: a parse-and-rebuild round trip silently discards comments, CDATA sections, processing instructions and the DOCTYPE, because none of them carry data. Here they all survive exactly as written.

Why simple elements stay on one line

An element whose only content is text — <title>Refactoring</title> — is kept on a single line instead of being split across three. A record with twenty such fields stays twenty lines rather than sixty, which is the difference between scanning it and scrolling it. Turn the option off if your diff tool prefers one token per line.

Common use cases

  • Reading a minified SOAP or API response pulled out of a log.
  • Tidying a hand-edited configuration file before committing it.
  • Making an XML payload legible for documentation or a bug report.

Frequently asked questions

How do I format XML online?

Paste your XML into the left panel and the indented result appears on the right immediately. Choose two spaces, four spaces or tabs to match your project, then copy or download the output.

Are comments and CDATA preserved?

Yes. Formatting operates on the markup itself rather than parsing the document into data and writing it back, so comments, CDATA sections, processing instructions and the DOCTYPE all survive exactly as written.

Why do some elements stay on a single line?

An element whose only content is text reads better on one line than split across three, and it keeps a long list of simple fields scannable. Turn the option off if you prefer every tag on its own line.

What happens if my XML is not well-formed?

Formatting stops and the first syntax error is reported with its line and column, because re-indenting markup that cannot be parsed would just produce a differently broken document.

Is my XML uploaded anywhere?

No. The document is formatted entirely in your browser and never sent to a server.

Related tools