Format and beautify XML code with proper indentation. Transform messy, unformatted XML into clean, readable code with consistent spacing and line breaks.
XML formatting (also called pretty-printing or beautification) transforms compact or poorly formatted XML into well-structured, readable code with proper indentation and line breaks. This makes XML documents much easier to read, debug, and maintain, especially for large configuration files, API responses, and data interchange documents.
Formatted XML = Proper indentation (2 or 4 spaces) + Line breaks between elements + Consistent attribute spacingXML formatting works by parsing the document structure and applying consistent indentation based on nesting depth. Each nested element gets additional indentation, attributes are aligned, and line breaks are inserted between elements to create a clean, hierarchical layout.
| Input | Output |
|---|---|
| <root><person><name>John</name><age>30</age></person></root> | <root> <person> <name>John</name> <age>30</age> </person> </root> |
| <config><debug>true</debug><port>3000</port></config> | <config> <debug>true</debug> <port>3000</port> </config> |
| <data><item id="1">A</item><item id="2">B</item></data> | <data> <item id="1">A</item> <item id="2">B</item> </data> |