XML Pretty Print
Pretty-print XML with clean indentation for easy reading. It runs entirely on your device — nothing is uploaded.
Example
Input
<r><x a="1"/><x a="2"/></r>
Output
<r>
<x a="1"/>
<x a="2"/>
</r>
How it works
The XML is parsed and re-emitted with tidy nesting and indentation.
Good to know
XML Pretty Print takes a block of compact, single-line, or inconsistently spaced XML and re-emits it with consistent nesting and indentation so the structure becomes readable at a glance. It's aimed at developers, QA engineers, and anyone who has to inspect XML pulled from an API response, a config file, a SOAP payload, or an export that arrived as one unbroken string. Because it parses the document before re-printing it, the output reflects the actual element tree rather than just adding line breaks blindly.
Reach for it whenever you need to read XML that a machine produced for machines: minified web service responses, RSS or sitemap feeds, Android or .NET XML config, SVG markup, or office document parts. Indented output makes it far easier to spot a misplaced closing tag, an unexpected nesting level, or a missing element when you're diffing two payloads or filing a bug report.
To read the result, follow the indentation as a map of depth: each step to the right is one level deeper in the tree, sibling elements line up in the same column, and a tag that opens and closes on the same line (like a self-closing <x a="1"/>) is a leaf with no children. If the input is not well-formed, a parser-based formatter will typically refuse to indent it or flag the error rather than guess, which is itself a useful signal that something upstream is broken.
One practical caveat: pretty-printing is for human reading, not for transmission. The added whitespace increases byte size and, in a few XML dialects where whitespace is significant (for example mixed text content inside elements), reformatting can subtly change meaning—so format a copy for inspection and keep the original for actual use, or run the result back through a minifier before shipping.
Frequently asked questions
Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.
People also ask
What is the difference between pretty-printing and formatting XML?
They overlap heavily and the terms are often used interchangeably. Pretty-printing specifically refers to adding indentation and line breaks so a document is easy to read, while formatting can also include normalizing attribute quoting, casing, or self-closing tags depending on the tool.
Does pretty-printing XML change the data inside it?
It changes only the layout—indentation and line breaks—not the elements, attributes, or their values. The one exception is whitespace inside text content, which is significant in some XML schemas, so reformatting can alter mixed-content meaning.
How do I make pretty-printed XML compact again?
Run it through an XML minifier, which strips the indentation and line breaks added for readability and collapses the document back to a single line. This reverses pretty-printing for storage or transmission.
Can I pretty-print invalid or broken XML?
A parser-based formatter generally cannot, because it must understand the element tree before it can indent it correctly. Malformed XML—unclosed tags, mismatched names, or stray characters—will usually trigger an error instead of formatted output.
Why does my XML appear as one long line?
Machine-generated XML such as API responses and config exports is typically serialized without whitespace to save bytes. The data is intact; it just lacks the line breaks and indentation that make it readable, which is exactly what pretty-printing restores.
What indentation does XML pretty-printing use?
Most tools default to two spaces per nesting level, though some allow choosing tabs or a different number of spaces. The choice is purely cosmetic and does not affect how the XML is parsed.
Is it safe to pretty-print XML that contains sensitive data?
With a client-side tool the XML is processed in your browser and is not uploaded, so sensitive payloads stay on your device. Always confirm a given tool runs locally before pasting confidential data into it.
Will pretty-printing fix encoding or escaping issues in my XML?
No. Pretty-printing only reorganizes layout; it does not escape special characters or repair encoding. Use a dedicated XML escape or validation tool for those problems.
Related tools