XML Formatter Online — Free XML Beautifier

Beautify XML with consistent 2-space, 4-space, or tab indentation. Normalize whitespace, repair self-closing tags, and fix mixed-content layout for SOAP, RSS, configs, and schemas — 100% in your browser.

What is an XML Formatter?

An XML formatter takes a single-line, minified, or inconsistently indented XML document and rewrites it with predictable indentation, line breaks, and self-closing tags. The structure and content stay identical — only the layout changes — so the result is byte-for-byte safe to commit, diff, and review.

SOAP envelopes from older WSDL services, RSS/Atom feeds, Spring and .NET configuration files, XLIFF translation bundles, and OOXML/SVG markup all arrive in the wild as one ugly line. The OpenFormatter XML formatter parses them with the browser's native DOMParser, then emits a clean tree using the indent width you choose. Nothing is uploaded, nothing is logged.

How to format XML online — 4 steps

  1. Paste your XML. Drop a SOAP response, RSS feed, or any .xml source into the Input panel. Click Load Sample for a demo book catalogue.
  2. Pick an indent width. 2 spaces (SOAP/RSS convention), 4 spaces (Java/.NET convention), or Tab. The formatter applies it to every nested level.
  3. Click Format. Parsing and pretty-printing happen client-side in milliseconds. A green Valid badge confirms success.
  4. Copy the result. Use the Copy button to send the beautified XML straight to your editor or commit.

Sample input vs formatted output

Before — minified

<catalog><book id="bk101"><author>Gambardella</author><title>XML Guide</title><price>44.95</price></book></catalog>

After — 2-space indent

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <book id="bk101">
    <author>Gambardella</author>
    <title>XML Guide</title>
    <price>44.95</price>
  </book>
</catalog>

Configurable Indent

Switch between 2-space, 4-space, or tab indentation in one click. The width applies uniformly across every nesting level of the document.

Self-Closing Repair

Empty elements written as <foo></foo> are normalized to <foo/>, matching canonical XML and trimming bytes without altering semantics.

Client-Side Only

XML is parsed and serialized inside your browser using DOMParser and JavaScript. SOAP payloads with secrets stay on your machine.

Common use cases

  • check_circleBeautifying SOAP request/response envelopes during web service integration
  • check_circleFormatting RSS, Atom, and podcast feed XML before publishing or auditing
  • check_circleIndenting Spring, Hibernate, log4j, and .NET app.config files for code review
  • check_circleCleaning up auto-generated XML from build tools, ORMs, and code generators
  • check_circleMaking XSD schema files readable before authoring or modifying them
  • check_circlePretty-printing XLIFF translation bundles before localization handoff
  • check_circleReformatting XML log lines pulled from journald or message buses for triage
  • check_circleIndenting OOXML fragments (Word, Excel) extracted for forensic analysis

Format vs minify vs validate

Three operations, three goals. Formatting (this tool) adds whitespace to make XML readable for humans. Minification strips that whitespace back out for storage and bandwidth. Validation ignores layout entirely and confirms the document is well-formed (matched tags, correct escaping). Most workflows pair format-on-checkout with minify-on-deploy, with a validator running in CI between the two.

Need to do more than format?

Minify, validate, view as a tree, or convert XML — all browser-side, all free.

Frequently Asked Questions

What indentation widths does the XML formatter support?

Three options: 2 spaces (the most common convention for SOAP, RSS, and Atom), 4 spaces (often used in Java and .NET XML configuration), and tab characters. Pick the option that matches your team style guide before clicking Format — the formatter applies it to every nesting level.

Does the formatter convert empty elements to self-closing tags?

Yes. Any element with no children and no text content is emitted as a self-closing tag (e.g. <empty/>) rather than an open/close pair (<empty></empty>). This matches the canonical XML serialization rule and reduces file size without changing the document semantics.

Is attribute order preserved during formatting?

Yes. The formatter walks the parsed DOM in document order and emits each element's attributes in the order they appeared in the source XML. Attribute names and quote characters are kept exactly as parsed — the formatter does not re-sort or alphabetize them.

What gets normalized and what stays untouched?

Normalized: whitespace between elements, indentation depth, blank lines, and the layout of mixed-content nodes. Untouched: attribute values, text content (the actual characters inside an element), CDATA sections, processing instructions, and namespace declarations.

Will formatting damage XML with mixed content?

Mixed content (an element containing both text and child elements, like XHTML paragraphs) is the trickiest case. The formatter detects elements with significant text content and keeps the original layout for those nodes — it only re-indents around elements whose children are purely structural.

Does the formatter preserve XML namespaces and prefixes?

Yes. xmlns and prefixed declarations (e.g. xmlns:soap="...") are emitted verbatim on the elements where they appear, and prefixed element/attribute names (soap:Body, xsi:type) are kept intact through formatting.

Is my XML uploaded to your servers?

No. The formatter uses the browser's built-in DOMParser and a JavaScript serializer running on your machine. SOAP envelopes containing tokens, signed payloads, or proprietary business data never leave your device. Verify in DevTools → Network: clicking Format produces zero requests.

How is this different from XML Pretty Print on this site?

Functionally they are the same operation — both indent XML for readability. The Formatter page is the canonical tool with the full feature set; the Pretty Print page exists because that phrasing is more common in some communities. If you came here looking for "pretty print", you are in the right place.

XML Formatter Online — Free XML Beautifier | OpenFormatter