Skip to content

XML Formatter

XML Formatter pretty-prints or minifies XML in your browser. Paste an XML document or fragment, parse it locally with DOMParser, then copy two-space indented or compact output. Nothing is uploaded, stored in localStorage, or sent to a remote formatter API. Malformed XML is rejected next to the input rather than silently repaired.

Paste an XML document or fragment and format it locally — pretty-print with two-space indentation for reading and review, or minify to a single line. Closing the tab drops the workspace; we do not write it to localStorage or send it to a formatter API. This page is an XML beautifier / pretty-printer for text you already have, not an XSD/DTD validator and not a SOAP client.

Formatting runs against the browser's own DOMParser. If the document is not well-formed — an unclosed tag, a stray ampersand, mismatched namespaces — the page shows a parse error next to the input instead of guessing at a fix. Attributes, namespaces, and CDATA sections are preserved as written; this page reflows whitespace between elements, it does not rewrite your markup.

XML workspace

Pretty

Paste an XML document or fragment. Well-formedness only — not an XSD/DTD validator. Nothing is uploaded.

Output

Whitespace formatter only — not an XSD/DTD validator or SOAP client. Closing the tab drops the workspace.

How does the XML Formatter work?

  1. 1. Paste XML

    Drop in an XML document or fragment. An example (a tiny fictional book catalog) is available from Load example.

  2. 2. Parse locally

    The browser's DOMParser runs in this tab. Malformed XML — an unclosed tag, a stray ampersand, mismatched namespaces — gets an error next to the input; nothing is sent anywhere.

  3. 3. Pretty-print or minify

    Choose two-space indented output for reading and review, or a single-line minified form. Attributes, namespaces, and CDATA content are preserved as written; only inter-element whitespace changes.

  4. 4. Copy the result

    Copy the formatted XML. Closing the tab drops the workspace.

Questions about XML Formatter

What does this XML formatter do?
It pretty-prints or minifies XML in your browser. Paste an XML document or fragment, and it reformats the whitespace between elements — two-space indentation for reading and review, or a single compact line. It parses your XML with the browser's DOMParser first, so anything that is not well-formed is rejected with an error rather than silently patched.
Does it upload my XML?
No. Parsing and formatting run entirely in the browser with DOMParser and XMLSerializer. There is no account, no server-side formatter, and no file upload. The text you paste stays in this tab until you clear it or close the page. We do not write it to localStorage. That is the same privacy rule as JSON Formatter and SQL Formatter on this hub.
What happens if my XML is invalid or malformed?
You get a short error next to the input — for example, an unclosed tag or an invalid character — and the output stays empty. The page does not guess at a fix, auto-close tags, or escape characters on your behalf. Correct the XML in an editor and paste again.
How is this different from JSON Formatter on this hub?
JSON Formatter parses and formats JSON with JSON.parse / JSON.stringify. This page parses and formats XML with the browser's DOMParser/XMLSerializer instead — a different language with different syntax rules (tags and attributes, not braces and colons). They do not convert between the two formats; each one only reads its own language.
What is the difference between Pretty and Minify?
Pretty adds two-space indentation per nesting level so the structure is easy to read and diff. Minify strips whitespace-only text between elements and collapses the document to a single line, which is useful for pasting into a config field or a compact log line. Neither mode changes element order, attribute values, or text content — only inter-element whitespace.
Can it handle very large XML files?
The page is meant for typical documents and config-sized fragments. Very large files (many megabytes) can strain browser memory and slow down the tab, because parsing builds a full DOM tree in memory. There is no upload size limit, because nothing is uploaded — the limit is your browser's memory and responsiveness. For multi-megabyte exports, prefer a local CLI formatter.
Does it change my attributes, namespaces, or CDATA sections?
No. Attribute order and values, namespace prefixes and URIs, and the content of CDATA sections and comments are preserved exactly as written. This page only reflows the whitespace between elements — it is a whitespace formatter, not a namespace normalizer or a content rewriter.
Is this an XML schema validator or a SOAP client?
No. It only checks that the XML is well-formed enough for the browser's parser to build a document — it does not validate against an XSD or DTD, does not resolve external entities or DOCTYPE references, and does not send or receive a SOAP request. If you need schema validation, use a dedicated XSD validator; this page stops at "is this well-formed XML."

These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.