XML Pretty Print Online — Format & Indent XML

Apply consistent indentation depth across every nested element and wrap your XML for readability. Indent-only operation — for the canonical tool with the same engine, see the XML Formatter.

What is XML Pretty Print?

Pretty printing XML means re-emitting the document with consistent indentation depth so each level of nesting is visually distinct. It is an indent-only operation — element names, attribute values, and text content are preserved bit-for-bit. The output is the same XML, just laid out for human eyes.

For XML, "pretty print" and "format" describe exactly the same operation. We provide both pages because vocabulary differs by community: SQL Server DBAs, Oracle developers, and older Java tooling tend to say "pretty print", while modern editors and IDEs say "format". The engine behind both pages is identical. If you came here from a search, you are in the right place — but for the canonical, fully-featured tool, head to the XML Formatter.

How to pretty print XML online — 4 steps

  1. Paste your XML. Drop a single-line or inconsistently indented document into the Input panel. Click Load Sample for a small note example.
  2. Pick indent width. 2 spaces, 4 spaces, or Tab — the same depth is applied to every nesting level.
  3. Click Pretty Print. The document is parsed client-side and re-emitted with consistent indentation.
  4. Copy the result. Use the Copy button to grab the indented XML for your editor or commit.

Sample input vs pretty output

Before — single line

<note priority="high"><to>Tove</to><from>Jani</from><body>Don't forget!</body></note>

After — 2-space depth

<?xml version="1.0" encoding="UTF-8"?>
<note priority="high">
  <to>Tove</to>
  <from>Jani</from>
  <body>Don't forget!</body>
</note>

Consistent Indent Depth

Every nested element gets exactly one extra indent level. Deeply nested SOAP and config XML lines up cleanly with no surprise jumps in indentation.

Width Control

Pick 2-space, 4-space, or tab indentation up front. The chosen width applies uniformly to every level — no per-element overrides.

Indent-Only Operation

The pretty printer never reorders attributes, normalises values, or rewrites entities. Only whitespace between elements changes between input and output.

Common use cases

  • check_circlePretty-printing minified SOAP XML before pasting into a bug report
  • check_circleIndenting database XML exports (SQL Server FOR XML, Oracle XMLType) for review
  • check_circleFormatting auto-generated XML from JAXB, .NET XmlSerializer, or T4 templates
  • check_circleIndenting XML literals copied from log files or stack traces
  • check_circlePretty-printing inline XML embedded in unit-test assertions
  • check_circleCleaning up XML pulled from queue messages (IBM MQ, RabbitMQ) for triage
  • check_circleIndenting XML configuration before authoring or modifying Spring/log4j files
  • check_circleFormatting XLIFF translation bundles before localization handoff

Pretty print = format (and that is fine)

In some technical communities (HTML/CSS, Python, JSON) "pretty print" and "format" describe distinct operations. In XML, they do not — both names refer to indenting the document for readability. We maintain a separate Pretty Print page so search engines can match the phrase users actually type, but the engine is the same one powering the Formatter. If you need extras like attribute reordering or namespace canonicalisation, those live elsewhere — this page focuses purely on indent depth.

Want the canonical tool — or something else?

The XML Formatter is the same operation under a different name. Or minify, validate, or convert your XML — all browser-side.

Frequently Asked Questions

Is "pretty print" the same thing as "format"?

Yes — for XML, "pretty print" and "format" are two names for the same operation: parse the document, then re-emit it with consistent indentation. Some communities (especially Java and database tooling) use "pretty print" while others use "format". Both end up at the same place. The canonical version of this tool lives at the XML Formatter page; this page exists to match the wording you searched for.

How deep does the indentation go?

There is no fixed limit — every nested element gets one additional indent level. A SOAP envelope typically reaches 5–8 levels deep; XML configuration files (Spring, log4j) can hit 10+. The pretty printer scales linearly: deeper trees just produce longer lines of leading whitespace, never a depth cap.

Does the pretty printer wrap long attribute lines?

No — attributes stay on the same line as the element they belong to, even when an element has many of them. This matches the behaviour of most XML formatters and is the default convention for SOAP, XHTML, and Spring beans. If a single line gets long, scroll horizontally; the alternative (one attribute per line) breaks tooling that expects elements on a single line.

Why have a separate "pretty print" page if it equals "format"?

Search behaviour. Some developers (especially those coming from SQL Server, Oracle, or older Java tooling) only use the term "pretty print" — they will not type "format" into a search box. Having both pages with the same engine ensures everyone reaches the right tool regardless of vocabulary. For the canonical, fully-featured tool, see the XML Formatter.

Will pretty-printing change attribute order or values?

No. The pretty printer is indent-only — it walks the parsed DOM in document order and emits attributes exactly as they appeared. Attribute names, quote characters, values, and namespace prefixes are preserved. The only thing that changes between input and output is whitespace.

Does pretty-printing damage CDATA or processing instructions?

No. CDATA sections (<![CDATA[ ... ]]>) and processing instructions (<?xml ?>, <?xml-stylesheet ?>) are passed through verbatim. The indent operation only touches whitespace between elements, so embedded code, scripts, and binary text inside CDATA survive unchanged.

Can I pretty-print XML with mixed content?

Yes, with one caveat: elements that contain both text and child elements (think XHTML paragraphs with inline tags) are detected and left on a single line so the visible text reads correctly. Pretty-printing those nodes onto multiple lines would inject visible whitespace into the rendered text.

Is my XML uploaded to your servers?

No. Pretty-printing happens in JavaScript in your browser using the native DOMParser. Your XML never leaves the device. Confirm in DevTools → Network: clicking Pretty Print produces zero network traffic.

XML Pretty Print Online — Format & Indent XML