XML Formatter

Beautify XML.

Loading tool…

What is XML?

XML — Extensible Markup Language — was standardised by the W3C in 1998 as a general way to describe structured documents with tags you define yourself. It underpins a great deal of infrastructure that is not going anywhere: SOAP web services, RSS feeds, SVG images, Office and OpenDocument files, Android layouts, Maven builds, and countless enterprise integrations.

Unlike JSON, XML distinguishes between elements and attributes, supports namespaces so vocabularies can be mixed in one document, allows comments and processing instructions, and can be validated against a schema. It is also verbose, and machine-generated XML usually arrives with no line breaks at all. Formatting parses the document and re-emits it with consistent indentation, which makes the element hierarchy visible and confirms the document is well-formed at the same time.

Why we built this tool

Anyone integrating with a bank, a government service, a shipping carrier, or an older enterprise system still spends time reading raw XML — usually a SOAP envelope or a settlement file dumped on one line in a log.

Those payloads carry account numbers, personal details, and authentication headers. Pasting them into an online beautifier sends real customer data to a third party for the sake of some indentation. Our formatter parses the XML with the browser's own built-in parser and re-serialises it locally, so the document never leaves the tab. No upload, no size ceiling, no login, and it keeps working offline once the page has loaded.

Tips and common mistakes

  • Namespace prefixes are meaningful; do not rename them to tidy the document.
  • Whitespace inside mixed-content elements is significant, so formatted output can differ subtly from the original for text-bearing nodes.
  • A stray ampersand that should be & is the most common cause of a well-formedness failure.
  • Redact authentication headers from SOAP envelopes before sharing them in a ticket.

Open XML Formatter with a link

Assistants and scripts can open XML Formatter with its input already in the link, after the #, which never leaves your device:

  • #text= — the text to work on

Example: https://mygadgets.ink/tools/xml-formatter/#text=... · also compressed gz fields and ?url=. How tool links work

Quick start: using XML Formatter

  1. Paste the XML you need to read into the input above.
  2. Set your preferred indentation width.
  3. Format the document; parse errors will point at where it is malformed.
  4. Read the indented structure to find the element you were looking for.
  5. Copy the formatted XML or download it as a file.

For the JSON equivalent, use JSON Formatter. To compare two documents line by line, try Diff Checker.

What formatting does

An XML formatter re-prints the markup with consistent indentation, placing each element on its own line and nesting child elements under their parents. The data and tags are unchanged; only whitespace is added. The payoff is that the document's hierarchy — which element contains which — becomes obvious at a glance.

Formatting as debugging

Like its JSON cousin, an XML formatter often finds the bug for you. When markup is malformed, the indentation goes visibly wrong at the point of the problem — an unclosed tag makes everything after it indent too deeply, and a stray closing tag breaks the nesting. Common issues formatting reveals:

  • Unclosed tags — an element opened but never closed.
  • Mismatched tags — closing </b> when you opened <a>.
  • Missing the root element — XML needs exactly one top-level element wrapping everything.
  • Unescaped characters — a raw &, <, or > inside text that should be escaped as &amp;, &lt;, &gt;.

XML's strict rules

XML is stricter than HTML. Every tag must close, tags must nest properly (no overlapping), attribute values must be quoted, and there must be a single root element. Formatting makes violations of these rules jump out.

Common uses

  • Read a SOAP or API response that came minified.
  • Debug a config or feed by seeing its structure.
  • Spot an unclosed tag the parser complains about.
  • Clean up hand-edited XML before use.

Related Developer Tools

Browse all Developer Tools →