Skip to main content
AllDevToolsHub
🧩

XML Formatter

100% Local

Format and pretty‑print XML locally.

XML Formatter
Parsing failed

XML formatter

Format and pretty-print XML using the browser parser and a simple indenter. Runs locally.

Try:

Privacy note

This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.

How to Use XML Formatter

01

Paste XML

Paste raw or minified XML into the input editor.

02

Set Indentation

Choose 2-space, 4-space, or tab indentation from the options.

03

Format or Minify

Click Format to pretty-print the XML, or Minify to compress it into a single line.

04

Copy Output

Copy the formatted XML to clipboard or download as a .xml file.

XML Formatter: the essentials

The XML Formatter cleans, validates, and pretty-prints minified XML, SOAP envelopes, RSS feeds, SVG, sitemaps, and enterprise payloads, using the browser's native parser. Indentation, attribute alignment, and structure visualization, all entirely client-side so confidential business data never leaves your machine.

Key points

  • Reflows xml formatter into clean, readable output with standard indentation and keyword casing.
  • Runs entirely in your browser, so production data never leaves your device.
  • Supports multiple dialects and syntax variants for broad compatibility.
Overview

What is XML Formatter?

Paste raw XML and get a clean, indented version using the browser parser and a simple formatter. Useful for cleaning up logs, API payloads, and config files.
FAQ

Frequently Asked Questions

Reference

Technical Deep Dive

XML Formatter

Paste raw XML and get a clean, indented version using the browser parser and a simple formatter. Useful for logs and API payloads.

xmllint --format is the Unix default. This formatter pretty-prints XML in the tab, including SOAP envelopes you should not upload.

Paste <root><id>1</id></root>. You should get indented tags. A missing closer must show a parse error, not a silent wrap.

It is not an XSD validator. Huge documents can stall the parser. DTDs that fetch network entities are rejected for safety.

01 XML Dialect Matrix

Dialect Standard Usage Hierarchy Complexity
SOAPEnterprise ServicesDeeply NestedHigh
SVGVector GraphicsFlat to MediumMedium
RSS/AtomContent SyndicationFixed SchemaMedium
XHTMLLegacy WebDocument-centricLow

02 Formatting Workflow

1
Lexical Analysis The raw XML string is parsed into a DOM tree, stripping existing non-significant whitespace and validating syntax rules.
2
Recursive Serialization The tree is traversed recursively, adding consistent indentation and line-breaks based on the hierarchy depth.
3
Entity Encoding Special characters are correctly escaped as XML entities (&lt;, &gt;, etc.) to maintain well-formedness in the final output.

03 Where XML Still Runs the World

JSON took the new APIs, but XML stayed put in enterprise, identity, publishing, and document interchange. These are the places you'll actually paste a 200KB blob into a formatter.

  • 🧼
    SOAP envelope debugging Legacy banking, insurance, and telco APIs still ship WSDL. A formatted <soap:Envelope> turns a one-line wire payload into a tree you can actually trace a fault through.
  • 🔐
    SAML 2.0 assertion inspection Decoded SSO assertions are dense, namespace-heavy XML. Formatting reveals the <saml:AttributeStatement> mapping so you can compare what your IdP sent vs. what your SP expected.
  • 📡
    RSS / Atom feeds Feed generators emit unindented output. Formatting before validating with a feed reader reveals missing <guid> or malformed <pubDate> entries.
  • 📄
    OOXML internals (.docx, .xlsx) Unzip a Word or Excel file and you'll find a tree of XML. Formatting document.xml or sheet1.xml is the only way to debug template-engine output that opens corrupted.
  • 🤖
    Android resource files strings.xml, layout XML, and AndroidManifest.xml all benefit from consistent indent when you're diffing localization PRs across 30 locales.

04 Worked Examples

EXAMPLE 1 · NAMESPACE PREFIX COLLISION
Two subtrees, same prefix, different URIs (legal XML):
<root>

<a:item xmlns:a="urn:catalog">Book</a:item>
<a:item xmlns:a="urn:order">Line 1</a:item>
</root>


After a naive formatter "tidies" by hoisting the namespace to root:

<root xmlns:a="urn:catalog">
<a:item>Book</a:item>
<a:item>Line 1</a:item> <!-- now bound to urn:catalog! -->
</root>

A correct formatter keeps each xmlns binding local. Per XML Namespaces 1.0, a prefix means whatever it was bound to at its scope, and SAML signature verification will fail loudly if you've silently rebound ds:.




EXAMPLE 2 · CDATA PRESERVATION

XSLT template carrying an inline script:

<script><![CDATA[
if (a < b && c > d) doThing();
]]></script>

A safe formatter leaves the CDATA contents byte-identical:

<script>
<![CDATA[
if (a < b && c > d) doThing();
]]>
</script>

Whitespace around the CDATA section can be normalized; the contents must not be touched, escaped, or re-indented. If a formatter rewrites && to &amp;&amp; inside the CDATA, it has a bug, that's exactly the escape CDATA exists to avoid.




EXAMPLE 3 · SELF-CLOSING vs EXPLICIT-CLOSE

Two ways to write an empty element:

<br/>
<br></br>

In strict XML / XHTML they're equivalent. In XML signatures (used by SAML), they aren't:

<!-- canonicalized form (c14n) always emits explicit close -->
<br></br>

XML Signature uses Canonical XML (c14n) to compute the digest. A formatter that rewrites <br/> to <br></br> on a signed assertion breaks the signature, same logical document, different bytes. Format before signing, never after.




05 Related Tools

XML lives next to conversion, schema, and security tools more than any other format. These are the ones we reach for most often.

Compare With

You Might Also Need