What is XML formatting?
XML formatting adds proper indentation and line breaks to XML documents, making them human-readable. This tool also validates well-formedness — checking that all tags are properly opened and closed, attributes are quoted, and the document structure is valid. All processing happens in your browser.
Formatting and well-formedness
An XML formatter parses your document and re-indents it so each nested element sits one level deeper than its parent. Because XML must be well-formed — every element closed, correctly nested, and with a single root — parsing to format also reveals structural errors such as a missing closing tag or overlapping elements.
The formatter preserves the XML declaration (prolog), attribute values, and the exact text content of elements, changing only the whitespace between tags.
Format to read, minify to transmit
Indented XML is easy to inspect; minified XML is compact for storage and transport. Minifying removes the whitespace between elements to reduce size, which matters for SOAP messages, RSS feeds, and configuration files sent over the network. Validation confirms the document is well-formed before you rely on it.
Working with feeds and config
Much of the XML developers meet is machine-generated — RSS and Atom feeds, SOAP messages, and app configuration. Those arrive as a single unbroken line, so formatting is often the first step to understanding them, and validation confirms the document is well-formed before you parse it in code.
How to format XML
- 1Paste your XML. Paste a document, feed, or configuration snippet into the input.
- 2Click Format. The document is re-indented by nesting depth. Use Minify to compress it or Validate to check well-formedness.
- 3Copy the result. Copy the formatted or minified XML into your project.
Examples
Format a compact document
Input
<note><to>Ada</to><body>Hi</body></note>
Output
<note> <to>Ada</to> <body>Hi</body> </note>
Well-formedness error
Every element must be closed and nested correctly.
Input
<a><b></a></b>
Output
Error: tag <b> is not closed before </a>
XML building blocks
The parts of an XML document.
| Part | Example |
|---|---|
| Prolog | <?xml version="1.0" encoding="UTF-8"?> |
| Element | <title>Hello</title> |
| Attribute | <book id="42"> |
| Comment | <!-- note --> |
| CDATA | <![CDATA[ raw <text> ]]> |
| Root element | exactly one per document |
Frequently asked questions
What does well-formed XML mean?+
Well-formed XML has exactly one root element, every tag closed, elements properly nested, and attribute values quoted. The formatter reports where these rules are broken.
Does formatting validate against a schema?+
It checks well-formedness (correct syntax and nesting), not validity against a specific DTD or XSD schema. Those are separate, stricter checks.
Will formatting change my data?+
No. Only whitespace between elements changes; element text, attributes, and CDATA sections are preserved exactly.
Why minify XML?+
Minified XML is smaller, which reduces bandwidth for feeds, SOAP requests, and stored documents. The content is identical.
Is my XML uploaded?+
No. Parsing, formatting, and validation happen locally in your browser.
Is it free?+
Yes — free and unlimited.
What is the XML prolog?+
The optional first line, such as <?xml version="1.0" encoding="UTF-8"?>, that declares the XML version and character encoding. The formatter preserves it.