XML Formatter
XML Formatter — runs in your browser. Inputs are not stored.
XML formatter
Parses with the browser DOMParser, then applies indentation.
How to use
- Paste the document in the XML field. You can leave a declaration as it is.
- Press Format and the browser parses the document, then shows an indented result.
- On a syntax error, part of the parse error is shown in red in the status field.
- On success, check the hierarchy in Result and take it with Copy result.
- Reset clears input, result, and the status message.
Key concepts
The XML formatter does not slice text roughly. It builds a tree with the browser document parser, then serializes each element with two-space indentation. Empty elements become self-closing; elements with only text stay on one line. If the original has an XML declaration, version and UTF-8 declaration are prepended again. The XML formatter is a good fit for making feeds, config files, and SOAP fragments easier to read. Attribute values are wrapped in quotes again, so mixed quotes in the original can still display safely.
If parsing fails, formatting stops and the start of the error text is shown in the status field, so fix unclosed tags first and try again. This XML formatter does not validate schemas or normalize namespace prefixes. Processing stays inside the tab, so internal XML samples are not left on a server. Unlike an HTML formatter, it produces no result when the markup is not well-formed. Formatting empty input only shows “Enter XML” and does not change the result.
Example
Paste <?xml version="1.0"?><root><a>1</a></root> and press Format: the declaration is one line, and root and a split into a hierarchy. If you do not close the a tag, an XML parse error appears in the status field. Formatting an empty field only shows “Enter XML.”
Related: HTML formatter · JSON formatter · SQL formatter
Frequently asked questions
How does the XML formatter show syntax errors?
If the document parser emits an error node, the status field shows an XML parse error and the start of the message in red, and the result field is not updated.
If there is an XML declaration, does it remain in the formatter result?
If the original starts with a declaration, the first result line gets version 1.0 and a UTF-8 declaration. Without a declaration, output starts from the element.
How are empty elements written in the XML formatter?
With no child nodes they serialize as self-closing tags; with text only they stay on one line between open and close tags.
Does the XML formatter indent invalid documents like an HTML formatter?
No. If parsing fails, formatting stops. Loose HTML fragments belong in the HTML formatter.
Is XML formatter input sent to a server?
No. Parsing and serialization happen only in the browser. Empty input only shows “Enter XML.”
Are XML formatter comments kept in the result?
Comment nodes are rewritten with indentation kept. Processing instructions and some special nodes may not be element-serialization targets.
Last reviewed: 2026-09-04