XML

XML Formatter

Turn minified or inconsistently indented XML into a readable hierarchy, and catch syntax errors as you go.

Private by design — your data never leaves your device.
✓ Free forever✓ No sign-up✓ No ads✓ Works offline once loaded

XML Formatter

Turn minified or inconsistently indented XML into a readable hierarchy, and catch syntax errors as you go.

Input

Your XML

Nothing is uploaded.

Output

Formatted XML

Your result appears herePaste on the left and select “Format XML”

XML arriving from APIs, integration middleware, log pipelines and legacy systems is frequently minified onto a single line or indented inconsistently by whatever tool last touched it. This formatter rebuilds the indentation so the element hierarchy is visible at a glance, and reports the exact line and column of any syntax error rather than silently guessing at a repair.

Formatting and validation happen in JavaScript on your own device. The document you paste is never transmitted to a server, which matters when the XML in question is a SOAP envelope carrying customer records or a configuration file containing credentials.

How it works

How to use the xml formatter

  1. 1

    Paste or upload your XML

    Paste into the input pane, drag a file onto it, or use Upload File. Files up to 10 MB are supported; larger documents are processed in a background thread so the page stays responsive.

  2. 2

    Choose your indentation

    Two spaces, four spaces, or tabs. The output re-renders immediately when you change the setting, so you can compare conventions before committing to one.

  3. 3

    Copy, download, or open the result

    Copy XML puts clean plain text on your clipboard with no highlighting markup. Download XML saves it with an .xml extension. Open in New Tab shows the raw formatted document on its own.

What the formatter preserves

A formatter must change whitespace and nothing else. This one keeps every part of your document intact:

  • The XML declaration, including its encoding and standalone attributes
  • Namespace declarations and prefixed element and attribute names
  • Comments, CDATA sections, processing instructions and the DOCTYPE
  • Attribute order exactly as written, because XML attribute order is not semantically meaningful but diffs are

Mixed content — an element containing both text and child elements, as in <p>Hello <b>world</b></p> — is deliberately left on one line. Reflowing it would insert whitespace into the text node and change what the document means.

Well-formed versus valid

This tool checks that your XML is well-formed: every opening tag has a matching close in the correct nesting order, attribute values are quoted, reserved characters are escaped, and there is exactly one root element. That is the XML 1.0 syntax contract, and it is what a parser enforces before any application logic sees your data.

It does not perform schema validation. Checking a document against an XSD or DTD requires the schema itself, and asserting that a document "is valid" without one would be misleading. If a tool claims to validate arbitrary XML with no schema supplied, it is checking well-formedness and calling it something grander.

Working with SOAP, RSS, SVG and XSD

SOAP envelopes and enterprise integration payloads lean heavily on namespace prefixes such as soap:, ns1: and xsi:. Those prefixes and their declarations are preserved exactly; nothing is rewritten to shorten the output, because a prefix that goes out of scope changes the meaning of every element beneath it.

RSS and Atom feeds, SVG graphics, XSD schemas, Maven POMs, Android layouts and .NET configuration files are all ordinary XML and format the same way. Very large schemas — the W3C XMLSchema.xsd is around 88 KB and 2,100 lines formatted — are handled without trouble.

Common questions

XML Formatter FAQ

Is my XML uploaded to a server?

No. Parsing, validation and formatting all run in JavaScript in your browser. You can confirm this by opening your browser DevTools Network tab and formatting a document — no request is made.

Can it format minified or single-line XML?

Yes. That is the primary use case. Paste a one-line document and the formatter expands the full hierarchy using your chosen indentation without altering the structure.

Does it validate against an XSD or DTD?

No. It validates well-formedness — matching tags, quoted attributes, correct escaping, a single root. Schema validation requires you to supply the schema, which this tool does not currently accept.

What is the maximum file size?

Ten megabytes. Actual performance depends on your device, since all the work happens locally. Documents of a few megabytes format in well under a second on typical hardware.

Why is some of my XML left on a single line?

Elements containing both text and child elements are mixed content, where whitespace is significant. Adding line breaks inside them would change the text your application reads, so they are preserved verbatim.