XML Formatter

XML Formatter

Updated August 20, 2026

XML formatter and beautifier online. Pretty print XML, format messy SOAP or RSS, and see the first parse error instantly. Free XML pretty print in your browser.

Indent

Input XML

0 lines · 0 chars

Loading editor...

Formatted XML

0 lines · 0 chars read-only

Loading editor...

Features

  • XML formatter and beautifier that pretty prints XML in your browser
  • Choose 2-space or 4-space indent like other code formatters
  • See the first XML parse error instead of rewriting broken input
  • Keep the XML declaration, comments, attributes, and CDATA
  • Copy or download formatted XML with one click
  • Free XML pretty print online. Nothing is uploaded

Common Use Cases

  • Pretty print minified XML from an API or SOAP response
  • Format XML so a code review is readable
  • Beautify an RSS feed, Maven POM, or Android layout
  • Fix “one long line” XML before you debug it
  • Prepare a sample XML file for a test

What is an XML formatter (XML beautifier)?

An XML formatter (also called an XML beautifier or XML pretty printer) adds line breaks and indentation so you can read the tree. Search for “pretty print XML” or “format XML online” and this is the job: take compressed XML and make tags nest visually.

Formatting does not change the meaning of element-only XML. Parsers ignore extra spaces between tags. This tool parses in your browser, then writes the tree with a consistent indent. It will not invent a missing close tag. If the XML is invalid, you get the error instead of a guess.

Comments and CDATA are kept. Use this page as a free XML formatter online for SOAP, RSS, config files, and any well-formed XML. Nothing is uploaded.

Examples

Valid - Minified (valid)
<root><item id="1">Hello</item></root>
Invalid - Unclosed tag
<root><item>Hello</root>
Valid - With declaration
<?xml version="1.0" encoding="UTF-8"?>
<root/>

Frequently Asked Questions

How do I pretty print XML online?

Paste XML into this XML formatter, pick 2 or 4 spaces, and copy the result. That is the same as an XML beautifier or “XML pretty print” tool.

Does formatting change the meaning of my XML?

Not for element-only documents. Mixed content (text and child tags in the same parent) can lose extra spaces we treat as insignificant. If a schema cares about that whitespace, keep a copy of the original.

Why did my comments disappear in another tool?

Some converters round-trip through a data model that has no comment nodes. This formatter walks the DOM and writes comments back. JSON conversion will still drop them.

Can I format a 20 MB dump?

The work happens in this tab’s memory. Very large files can freeze the page. Split the document or use a local CLI (xmllint --format) for multi-megabyte logs.

Is this the same as HTML pretty-print?

No. HTML is parsed with an HTML parser that invents missing tags. XML is strict. A stray & or unclosed tag is an error here.

Tips

  • Keep a copy of production XML before pretty-printing if a downstream system hashes the exact bytes.
  • If the error mentions line 1 column 1, look for a UTF-8 BOM or HTML pasted by mistake.
  • Use 2-space indent for diffs. 4-space indent is fine for reading, noisier in Git.