Category: Developer tools

XML Formatter

System ideaMissing a tool?

Parse XML, then re-indent with 2 or 4 spaces or compact it back down

Paste XML, let the browser DOMParser check it is well-formed, then re-indent it with 2 or 4 spaces or minify it. Copy the result with an element and character count.

Paste XML to format or minify it.

Result
The result will appear here.

Everything on this page is processed in your browser. Nothing is uploaded.

What this tool does

Paste XML and the page parses it first with the browser's own DOMParser. If it parses, the markup is well-formed; if it does not, you get the error rather than a tidy-looking result built on broken structure. From there the tool goes in either of two directions. Formatting re-indents nested elements with two or four spaces so the hierarchy is readable at a glance, which is what you want with an API response or a config file that arrived as one long line. Minifying does the opposite: it removes the formatting whitespace between rendered nodes and compacts the document. Either output can be copied, and an element and character count is shown as a status line. During serialization the XML declaration, attributes, comments, CDATA sections and processing instructions are preserved as the serializer handles them, and special characters in text and attribute values are properly escaped. Two boundaries are worth being clear about. The first is validation: this checks that markup is well-formed, and nothing more. There is no XSD, DTD, namespace-policy or business-rule validation, so a document that formats cleanly has not been checked against a schema. The second is scope: no XPath queries, no XSLT transformation, no XML-to-JSON conversion, no file upload and no tree editor. One behavioural note as well — formatting normalises whitespace-only text nodes, so the output will not necessarily match the source byte for byte, and whitespace-sensitive element text is worth reviewing afterwards. Input is bounded by browser memory, with no streaming. Pasted XML and formatted output stay in your browser and are never uploaded to LocalTools.

How to use it

  1. Paste your XML into the input area; DOMParser checks whether the markup is well-formed.
  2. Choose 2-space or 4-space indentation to pretty print, or switch to the compact mode to minify.
  3. Copy the result and check the element and character count; parse errors are reported instead of a broken output.

Privacy

This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.

Frequently asked questions

What does an XML formatter do?
It re-indents markup so nesting becomes visible: every child element sits one level in from its parent, with consistent line breaks. A single-line API response turns into something you can actually read.
Does formatting change the XML data?
Elements, attributes and text content are preserved, and special characters are escaped correctly on output. What does change is whitespace between nodes, which is normalised, so the result is not a byte-for-byte copy of the source layout.
What happens when XML is malformed?
DOMParser reports the failure and the page shows the error instead of formatting. Unclosed tags, mismatched attribute quotes and more than one root element are the usual culprits.
Does it validate XSD or DTD?
No. It checks that the document is well-formed and stops there. Schema validation against an XSD or DTD, namespace policies and business rules are all outside this tool, so formatting successfully is not a conformance result.
Is my XML uploaded to a server?
No. Parsing, formatting and minifying all happen in your browser, and neither the pasted markup nor the output is sent to LocalTools. There is no file upload either, and no XML-to-JSON, XPath or XSLT features.