Developer guide
How to format XML without damaging data
XML formatting can indent element-only content for readability, but whitespace is data in XML and must be preserved in mixed, signed, or explicitly sensitive documents.
Open the XML FormatterWhat safe XML formatting requires
An XML formatter must parse a well-formed document before adding indentation. Element-only content is usually suitable for pretty printing, while text mixed with child elements may change if spaces are inserted or removed.
The ToolPixels formatter leaves mixed content, CDATA sections, and xml:space="preserve" subtrees together rather than indenting inside them.
How to format XML
- Paste XML or open a UTF-8 file.
- Choose two spaces, four spaces, or tabs.
- Select Format XML.
- Correct any well-formedness error before retrying.
- Review serialization changes and whitespace-sensitive regions before saving.
An element-only example
Input
<tools><tool>Formatter</tool><tool>Validator</tool></tools>
Formatted
<tools>
<tool>Formatter</tool>
<tool>Validator</tool>
</tools>
Serialization can change surface syntax
A parsed and serialized document may normalize quote styles, entity forms, empty elements, encoding declarations, and line endings. These can represent equivalent XML data while producing different bytes.
That distinction matters for digital signatures, byte-for-byte comparisons, and systems that incorrectly depend on a particular lexical form.
When not to pretty-print XML
- Signed XML can break when bytes change.
- Mixed content can gain visible spaces.
xml:space="preserve"signals that whitespace matters.- DTD and custom entity declarations are not supported by this tool.
- External documents are never loaded.
Use a schema-aware workflow when XSD validation or application-specific normalization is required.
Open the ToolPixels tool
Format well-formed XML locally with selectable indentation and protections for mixed or preserved content.