XML Beautifier
Pretty-print XML and catch well-formedness errors.
XML Beautifier – XML Pretty Print Online
XML from APIs, exports, and log files often arrives as one long line. The XML beautifier parses the document and prints it again with every element on its own line and child elements indented, so the structure is visible at a glance.
How to pretty print XML
- Paste XML, open an
.xmlfile, or click Sample. - Choose 2 spaces, 4 spaces, or tabs.
- Decide whether comments should be kept.
- Copy or download the formatted XML.
What the formatter preserves
- The XML declaration (
<?xml version="1.0" encoding="UTF-8"?>) and processing instructions. - Attributes and their order, namespaces and prefixes.
- Text content, CDATA sections, and entity references.
- Comments (unless you switch them off) and the DOCTYPE.
Elements that contain only text stay on one line (<title>Midnight Rain</title>), and empty elements are written as self-closing tags.
Well-formedness check included
The beautifier uses a strict XML parser. If a tag is not closed, attributes are not quoted, or the document has two root elements, you get a precise error with the line and column instead of output that looks right but is broken. That makes it a quick validator for config files and API payloads.
Typical uses
Read SOAP responses and RSS feeds, inspect Android layouts and Maven pom.xml files, review sitemap files, or prepare XML examples for documentation. Specialized versions exist for SOAP messages, WSDL files, SVG images, and XAML layouts.
Related XML tools
Shrink XML again with the XML Minifier, explore large documents in the XML Viewer, validate with detailed statistics in the XML Validator, or convert with XML to JSON.
Frequently Asked Questions
Does formatting change the XML data?
No. Elements, attributes, and text content stay the same. Only whitespace between elements is changed. If whitespace inside mixed content matters to your application, check the result before using it.
Why do I get an error for valid-looking XML?
XML is strict: every tag must be closed, attribute values need quotes, there must be exactly one root element, and characters like & must be escaped as &. The error shows the exact position.
Can it format HTML?
Only XHTML that is well-formed XML. For regular HTML with unclosed tags like <br> or <li>, use the HTML Beautifier.