/

XML Viewer & Formatter

Processed Client Side

Read XML as a collapsible tree, pretty-print it with the indentation you want, or minify it — with well-formedness checked as you type.

XML · 12 lines · 697 chars
12 lines · 697 charsLength: 697Lines: 12Size: 699 BytesCursor: 1:1
Tree
Well-formed17 elements · 10 attributes · depth 4
<!-- Inventory feed, generated nightly -->
<catalog xmlns:meta="https://example.com/meta" updated="2026-08-30T02:00:00Z">
<book id="bk-101" available="true">
<title>The Go Programming Language</title>
<author>Alan Donovan</author>
<author>Brian Kernighan</author>
<published year="2015" month="10"/>
<price currency="USD">39.99</price>
<meta:tags>
<tag>programming</tag>
<tag>go</tag>
</meta:tags>
<summary>Covers Go 1.5 & later — includes <goroutines>.</summary>
</book>
<book id="bk-102" available="false">
<title>Clean Code</title>
<author>Robert C. Martin</author>
<published year="2008"/>
<price currency="USD">44.50</price>
<notes/>
</book>
</catalog>

Bookmark this tool now — skip the search next time you need it.

About XML Viewer & Formatter

This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.

Paste an XML document — an RSS feed, a SOAP envelope, a Maven POM, an Android manifest, a sitemap, an SVG, a bank statement export — and read it three ways: as a collapsible tree you can fold down to the shape of the thing, as pretty-printed text with the indentation you choose, or minified onto one line. Well-formedness is checked as you type, and when the parser objects it tells you the line and column it stopped at rather than just refusing. XML arriving from a real system is usually either minified into a single unreadable line or indented by whoever generated it rather than by you, and both problems are the same problem: you cannot see the structure. The tree view fixes it by hiding the structure you are not looking at, the formatter by rewriting the whitespace, and neither one touches the data. Everything runs in your browser tab on the browser’s own XML parser, so a signed payload or a customer export is never uploaded.

Key features

  • Three views of the same document — an interactive tree, formatted text, and minified text — switched with one click and always in sync with the input
  • Collapsible tree with Expand all and Collapse all: fold a 4,000-line feed down to its root and open only the branch you care about
  • Well-formedness checked live, with the parser’s own message plus the line and column, and the offending line marked in the input pane
  • Syntax colouring in both panes and in the tree — tags, attribute names, attribute values, text, comments and CDATA each read differently
  • Your choice of indentation: 2 spaces, 4 spaces, or tabs
  • Minify that is still XML — whitespace between elements goes, the document stays well-formed, and the output reports how much smaller it got
  • Long start tags wrapped one attribute per line, so an element carrying eight namespaces stays readable instead of running off the pane
  • Options for the details that differ between generators: self-close empty elements (<notes/>) or write them out (<notes></notes>), keep or strip comments, keep or drop the XML declaration, and sort attributes alphabetically for diffing
  • Namespaces, prefixes, CDATA sections, processing instructions and DOCTYPE declarations all survive the round trip intact
  • Mixed content is left alone — an element holding both text and child elements is never re-wrapped, so the spaces inside <p>see <b>this</b> page</p> stay exactly where they were
  • Document stats above the output: element count, attribute count, distinct tag names, and nesting depth
  • Runs entirely in your browser on the built-in XML parser — no upload, no server, and it works offline once the page has loaded

How to use it

  1. Paste your XML into the left pane, or type it there directly.
  2. If it is not well-formed, read the error under the output — it names the line and column — and fix the marked line in the input.
  3. Stay on Tree to explore the document: click any element with children to fold or unfold it, or use Collapse all to see just the top level.
  4. Switch to Formatted for pretty-printed text, and pick 2 spaces, 4 spaces, or tabs.
  5. Switch to Minified to strip the layout whitespace for a payload or a config value.
  6. Adjust the switches if the output has to match a house style — self-closing tags, comments, the XML declaration, attribute order — then copy the result.

Tips & common mistakes

  • Collapse all first on a document you have never seen. What you get is the top level and nothing else, which is the fastest way to learn the shape of an unfamiliar feed — far faster than scrolling a formatted version of it.
  • The error line is the line the parser gave up on, not always the line with the mistake. An unclosed <item> on line 12 is reported at the point the parser meets a closing tag that cannot match, which may be hundreds of lines later. Work backwards from the reported line to the last tag you know was closed.
  • "Not well-formed" and "invalid" are different failures. This tool checks well-formedness — tags nested and closed correctly, one root element, attributes quoted, & and < escaped. It does not check the document against a DTD or an XSD, so a document that is perfectly well-formed here can still be rejected by a schema validator for having the wrong elements in the wrong order.
  • Unescaped ampersands are the single most common cause of a document failing here. A raw & in text or in an attribute — typically in a URL like ?a=1&b=2 — has to be written &amp;, because XML reads & as the start of an entity reference. The parser reports it as an unterminated entity, which is not an obvious description of the problem.
  • Sort attributes before diffing two documents. Attribute order carries no meaning in XML, but a text diff does not know that, so two identical documents from two generators can diff as different on every line. Sorting both and formatting both with the same indentation reduces the diff to the changes that matter.
  • Turn comments off to see the document a machine sees. Generated XML — POMs, manifests, exported configs — is often more comment than content, and stripping them makes the actual structure visible in a fraction of the lines.
  • Minifying is safe for data XML and risky for document XML. Whitespace between elements is layout and is dropped; whitespace inside an element that mixes text and markup is content and is kept. If your XML is records and fields, minify freely. If it is prose with tags in it, check the result before shipping it.
  • The declaration switch matters more than it looks. A stray <?xml ...?> anywhere but the very first character of a file is itself a well-formedness error, which is why an XML fragment being embedded into another document usually needs it turned off — and why a standalone file usually needs it on.
  • Namespace prefixes are kept exactly as written rather than normalised. A document using soap: and one using env: for the same namespace stay different here, because rewriting a prefix is a change to the document that only you can decide is safe.
  • A file that starts with a byte-order mark or a blank line before the declaration will fail to parse. Both are invisible in most editors; if a document looks perfect and still will not parse at line 1, delete everything before the first < and try again.
  • Once the structure is clear, send the document on: the XML to JSON converter turns it into JSON for code that would rather not carry an XML parser, and the JSON to XML converter comes back the other way.

Related tools

Browse all 2 XML tools

Frequently asked questions

13

Paste the document into the left pane, or open the file in a text editor and copy it across. It is parsed as you type and appears on the right as a collapsible tree — click any element that has children to fold or unfold it, and use Collapse all to reduce a large document to just its top level. Switch to Formatted for pretty-printed text instead. Nothing is uploaded: the parsing happens in your browser tab, so it works on payloads you would not want to send to a website.

Paste it and switch to the Formatted view. A document that arrived as one long line comes back indented one element per line, with your choice of 2 spaces, 4 spaces, or tabs. Only the whitespace between elements is rewritten — element names, attributes, text content and CDATA are untouched, so the formatted document says exactly what the original said.

It means the document breaks XML’s basic syntax rules before any question of what it contains: every tag closed and correctly nested, exactly one root element, attribute values quoted, and & and < escaped in text. The error under the output is the browser parser’s own message with the line and column it stopped at, and that line is marked in the input pane. Read it as "the parser could no longer make sense of things here" rather than "the mistake is here" — an unclosed tag is usually reported at the point a later closing tag fails to match it, so work backwards from the reported line.

Because XML reads & as the start of an entity reference, so a raw ampersand in text or in an attribute is a syntax error — the parser reports it as an unterminated entity, which does not sound like what it is. A URL such as page?a=1&b=2 has to be written page?a=1&amp;b=2 inside XML. The same applies to a literal < in text, which must be &lt;. This is the most common single reason a document fails to parse here.

No — it checks well-formedness, not validity. Well-formedness is syntax: tags nested and closed properly, one root, quoted attributes, escaped entities. Validity is a separate question of whether the document matches a DTD, an XSD, or a RELAX NG schema, meaning the right elements in the right order with the right types. A document can pass here and still be rejected by a schema validator, which is a different and much narrower kind of tool.

For data XML — records and fields, which is most XML you will meet — yes. Whitespace between elements is layout rather than content, and dropping it is exactly what a minifier is for; the output stays well-formed. Be careful with document XML such as XHTML or DocBook, where an element mixes text and markup: there the spaces are part of the text. This tool never re-wraps mixed content for that reason, so the spaces around an inline tag survive both formatting and minifying, but it is still worth checking the result before shipping prose.

Yes, all of them. Namespace declarations and prefixes are kept exactly as written rather than normalised, so a soap: prefix stays soap: and is not rewritten to something else; CDATA sections are emitted verbatim, brackets and all; processing instructions and a DOCTYPE declaration are carried through to the output. The only things you can choose to drop are comments and the XML declaration, and each has its own switch.

It decides how an element with no content is written: on, you get <notes/>; off, you get <notes></notes>. The two are identical to any XML parser, so this is purely about matching whatever house style or downstream tool you are feeding. It is worth turning off when the consumer is an old or hand-rolled parser, since a few of those handle the long form and choke on the short one.

To diff two documents. Attribute order carries no meaning in XML, but a line-based diff has no way of knowing that, so two documents that are semantically identical can show up as different on every line simply because two generators emitted their attributes in different orders. Format both with the same indentation and sort the attributes on both, and the diff collapses to the changes that actually matter.

It parses and formats up to about 2 MB, which covers most feeds, POMs, manifests and config files comfortably. Syntax colouring switches off above 60,000 characters — colouring allocates a node per coloured run and costs more than the parsing does — so a large document still opens and formats, it just renders in a single colour. Past 2 MB you will get a message rather than a frozen tab; split the document and do it in parts.

Keep it for a standalone file, and drop it for a fragment. The <?xml version="1.0"?> line is only legal as the very first thing in a document, so a fragment that will be pasted inside another document must not carry one — and by the same rule, a blank line or an invisible byte-order mark before the declaration is itself an error. If a document looks perfect and still fails to parse at line 1, delete everything before the first < character.

No. The parsing, formatting and minifying all happen in JavaScript in your browser tab using the browser’s own XML parser, and the page makes no network request with your document. Once the page has loaded it works offline, which is what makes it usable for a SOAP payload, a signed message, or an export containing customer data.

This one keeps the document as XML — it is for reading, reindenting and checking it. The XML to JSON converter changes the format, producing JSON for code that would rather not carry an XML parser, at the cost of some fidelity: XML attributes, namespaces and mixed content have no direct JSON equivalent, so the round trip is not lossless. Use this tool while you are working with the XML, and that one when you are handing the data to something else.