XML Parser

Parse XML and inspect its structure as a tree.

XML Input
Parsed Structure
paste XML to inspect its structure

Related Tools

Documentation

What is XML Parser?

XML Parser reads an XML document and renders it as a collapsible, searchable tree — the same interactive JsonTree view used by the JSON tools — so you can explore a document's shape without reading raw angle brackets. It's built for inspection, not for producing a converted file.

How it works

Input is parsed with the browser's native DOMParser in application/xml mode. If a parsererror node appears in the result, its message is shown in the error bar and, when the browser's error text includes a line number, that line is highlighted in the input gutter. On success, the document's root element is walked recursively: each attribute becomes a key prefixed with @, repeated sibling tags are grouped into arrays, and an element with no child elements collapses to its plain text content (or an object with an @attr/#text shape if it also has attributes or text). The resulting object is handed to the tree view for display — the tool never generates a text output panel.

Features

  • Collapsible, searchable tree view of the parsed structure
  • Attributes shown as @-prefixed keys alongside child elements
  • Repeated sibling tags automatically grouped into arrays
  • Line-highlighted parse errors in the input editor
  • Load a .xml file directly from disk

Example

Input: <tools><tool id="1">json-formatter</tool><tool id="2">yaml-formatter</tool></tools>

Tree view shows (conceptually, as the underlying object):

{
  "tools": {
    "tool": [
      { "@id": "1", "#text": "json-formatter" },
      { "@id": "2", "#text": "yaml-formatter" }
    ]
  }
}

Common errors

The most common failure is more than one root element, or a tag that's opened but never closed — both trip the DOMParser's parsererror and prevent a tree from rendering at all. Unlike a schema validator, this tool only checks well-formedness as a side effect of parsing; it doesn't verify tags against an XSD or DTD.

Best practices

Use this tool when you need to understand an unfamiliar XML document's shape — which elements repeat, which carry attributes — before writing code against it. If you actually need the data as a JSON file to consume elsewhere, use XML to JSON instead; this tool's tree view isn't downloadable.

Frequently Asked Questions

What does this show that the XML Formatter doesn't?

It shows the parsed structure as a JSON-like collapsible tree, rather than reformatted XML text — useful for understanding a document's shape at a glance.

How are attributes shown in the tree?

Prefixed with @, alongside the element's other keys, so you can tell attributes and child elements apart.

Is my XML uploaded anywhere?

No — parsing runs entirely in your browser via the native DOMParser.