XML Formatter — Pretty-Print, Validate and Minify XML without Changing Data
Pretty-print, minify & check well-formed closing tags on XML configs.
✓ Well-formed XML: 11 elements, 7 attributes, depth 4.
- White space is only added or removed between elements that hold no text. Mixed content (text next to elements), xml:space="preserve", CDATA and entity references are written exactly as in the source, so the data does not change.
When to use the XML Pretty-Printer, Minifier & Well-Formed Validator
The data stays the same
White space is only added or removed between elements that hold no text. Mixed content, xml:space="preserve", CDATA and entity references are written exactly as in the source.
Tested with ElementTree
For every test document, the formatted element tree equals the original according to Python's ElementTree, and formatting the result again changes nothing.
Validation included
Before formatting, documents are checked by a parser that passes the 1724 W3C XML 1.0 Fifth Edition cases, with the line and column of every error.
Pretty or compact
Choose a 2-space, 4-space or tab indent, or compact it onto one line; comments can be removed. The XML declaration, DOCTYPE and processing instructions are kept.
Frequently asked questions
Are attributes reordered?
No. Attribute order and the escaping of their values are kept; only the spacing between attributes is tidied.
Is the DTD reformatted?
No. The DOCTYPE is written as it is, but its entities and default attributes are still checked.
What does the minify mode do?
Minify removes the white space between elements that hold no text, so the document becomes one smaller line, for example to send it through an API or store it in a database.
What about large files?
Everything runs in the browser; files of a few megabytes usually finish within seconds.
Is my data uploaded?
No. Processing runs in your browser.
Similar tools
- HTML Beautifier & Indentation PrettifierRe-indent messy single-line HTML markup into readable nested element trees.
- HTML Whitespace & Comment MinifierCompress HTML documents by removing redundant whitespace & HTML comments.
- HTML to Clean GitHub Markdown ConverterConvert headings, links, bold/code tags & lists from HTML into clean Markdown.
- Markdown Live Previewer & HTML GeneratorWrite Markdown and simultaneously render clean semantic HTML & live preview.