Paste XML, open a file or press Sample, and the tree appears here.

Paste XML, open a file or press Sample. The tree builds as you type, and any error shows its line and column.

Selected node

Select a row in the tree to see its XPath, line, attributes and text.

Send the result to: XML Formatter XML Minifier

About the XML Viewer

What is an XML viewer?

An XML viewer shows an XML file as a tree you can open and close, one element per row.

Our viewer builds that tree as you type or open a file. It shows the parts of the file in their original order, including text between elements, comments, CDATA sections and processing instructions, and it never changes the XML.

Select any row to see its XPath, line number, attributes and text, or switch to Table to read repeated elements as rows.

What should you know before you view XML?

  • Nothing leaves your device. The XML is parsed on the page, and search and XPath run there too.
  • Broken XML is never guessed at. If a tag isn't closed, the viewer names the line and column and waits for a fix, instead of drawing a tree that doesn't match the file.
  • Entities show as characters. &, < and character references like © appear as the characters they stand for, and CDATA text appears exactly as written.
  • Every element has its own XPath. Select a node to copy a path like /catalog/product[2]/name that points to that element and no other.
  • Large files stay responsive. Long lists show 200 rows at a time, and search still covers every node.

How do you view an XML file as a tree?

  1. Add your XML. Paste it, click Open file, or drop a file on the XML box. Files such as .xml, .svg, .rss and .kml all work.
  2. Open the branches you need. Click an arrow, or use the arrow keys, to open and close elements.
  3. Select a node. The panel under the tree shows its XPath, line, attributes and text, and Show in editor highlights it in the XML.
  4. Search, or switch to Table. Search names, attributes and text, run an XPath expression, or read repeated elements as rows.

What do the rows in the XML tree mean?

Each row in the XML tree stands for one part of the file.

What each kind of row in the XML tree means
RowWhat it is
<product id="p-101">An element with its attributes. An arrow in front means it has children.
<name> Mechanical KeyboardAn element that holds only text, shown on one row
Plain textText between elements, such as the words around a bold tag
CDATAA CDATA section, text the parser doesn't read as markup
<!-- ... -->A comment
<?xml ... ?>The XML declaration, or a processing instruction

How do you search XML with XPath?

Switch the search to XPath and type an expression in XPath 1.0, the query language for XML. Matching elements are highlighted, and an expression that returns a number, a string or true or false shows its result.

XPath examples that work on the XML viewer sample
XPathWhat it finds in the sample
//productAll 3 product elements
//product[@status='active']/nameThe names of the 2 active products
//product[price > 50]/nameThe names of the 2 products priced over 50
count(//product)The number 3
//*[local-name()='image']The media:image element, whatever its namespace

If the root element has an xmlns="..." attribute, its elements are in that namespace, and a plain name like //url matches none of them. Write //*[local-name()='url'] instead, the same way the viewer writes its own XPaths.

Common mistakes

The XML Viewer reports each of these mistakes with its line and column.

  • An & in the text breaks the XML. A bare & has to be written as &amp;. The status box names the line and column of the first one.
  • A blank line before <?xml ...?> is an error. The XML declaration must be the very first thing in the file. Delete anything before it, even a space.
  • A closing tag doesn't match its opening tag. XML names are case-sensitive, so <Item> closed by </item> is an error. The message names the line where the open element starts.

Common Use Cases

People use an XML viewer whenever an XML file is too long or too nested to read as text.

  • API responses. Read SOAP and other XML responses, and copy the XPath of a field for your code.
  • Sitemaps and feeds. Check the URLs in a sitemap or the items in an RSS feed, and copy them as CSV from the Table tab.
  • Config and project files. Find a setting in a Maven pom.xml, an Android layout or a .csproj file.
  • SVG files. See how an SVG's groups and paths are nested.
  • Data exports. Check the structure of an export before you convert it.

To indent the XML itself, use the XML Formatter. To turn it into JSON, use the XML to JSON Converter, and for a web page, use the HTML Viewer, which renders the page instead of showing its tree.

Frequently Asked Questions

How do you open an XML file?

Click Open file and pick it, or drop the file on the XML box. Any text editor opens XML too, but only as plain text.

How do you make an XML file readable?

View it as a tree in our viewer, where each element gets its own row. For indented source text instead, use the XML Formatter.

Is my XML uploaded anywhere?

No, the XML is read and parsed on your device. Nothing is sent to a server.

Can the XML Viewer open large files?

Yes, files of several megabytes work, because long lists show 200 rows at a time. Search and XPath still cover every node.

Does the viewer show CDATA and comments?

Yes, CDATA sections, comments and processing instructions all appear in the tree in their original order. CDATA text is shown exactly as written.

Can you view XML as a table?

Yes, the Table tab shows repeated elements, such as every <product>, as rows. Each attribute and child element gets a column, and you can copy or download the table as CSV.