XML Formatter
Developer Tools
Pretty-print XML documents with proper indentation, preserved attributes, and tidy nesting.
Runs entirely in your browserAbout XML Formatter
The XML Formatter takes any XML — SOAP responses, RSS feeds, Android manifests, SVG sources, configuration files — and rebuilds it with consistent indentation and one element per line. It uses `fast-xml-parser` in preserve-order mode, which means the structure (element order, attribute order, text content) is byte-faithful to the input; only whitespace changes.
This is the tool to reach for when an XML response is one long line, or when nested elements make it hard to spot a malformed tag. Indent depth is configurable (2 spaces, 4 spaces, or tab), and the formatter handles namespaces, CDATA sections, processing instructions, and empty elements correctly. Everything runs in your browser, so even XML payloads containing internal data stay on your machine.
How to use
- 1
Paste your XML
Drop the XML document or fragment into the input editor.
- 2
Choose indentation
Pick 2 spaces, 4 spaces, or Tab from the Indent dropdown.
- 3
Copy or download the output
Use Copy or Download (.xml) to take the formatted result.
Examples
Pretty-printing a flat XML document
A one-line XML document expands into a readable, indented hierarchy.
Input
<?xml version="1.0"?><books><book id="1"><title>Hyperion</title><author>Dan Simmons</author></book></books>Output
<?xml version="1.0"?>
<books>
<book id="1">
<title>Hyperion</title>
<author>Dan Simmons</author>
</book>
</books>Frequently asked questions
Does it validate the XML?+
Well-formedness is implicitly checked — malformed XML will surface a parse error. For DTD or XSD schema validation, use a dedicated XML validator.
Are namespaces preserved?+
Yes. Namespace prefixes (e.g. `xmlns:soap`) and their qualified usage stay exactly as written.
What about CDATA blocks?+
CDATA sections are preserved verbatim, including any whitespace inside them.
Does it sort attributes or elements?+
No. Attribute and element order are kept exactly as in the input. The formatter only changes whitespace.
Is my XML sent anywhere?+
No — parsing and formatting both happen in your browser.
Related tools
JSON Formatter
Format, beautify, and explore JSON with an expandable tree view. Includes indent control and minify.
JSON Validator
Validate JSON structure and pinpoint syntax errors by line and column.
HTML Formatter
Clean and indent messy HTML for better readability.
CSS Formatter
Format and organize CSS automatically with configurable brace and indent styles.
SQL Formatter
Beautify SQL queries with proper indentation across Postgres, MySQL, SQLite, and MSSQL dialects.
JSON to XML Converter
Convert JSON data into well-formed XML quickly.