b2KIT

HTML DOM Tree Viewer

Paste HTML and explore the parsed DOM tree with element attributes, nesting depth, and structure.

Tested tool guide Tested browser tools Checked August 16, 2026

What HTML DOM Tree Viewer does and how it behaves

HTML DOM Tree Viewer turns pasted markup into a browsable hierarchy of parsed elements. It exposes element names, attributes, parent-child nesting, and depth, letting you answer structural questions that raw indentation cannot settle. Use it to locate where a wrapper begins, which element owns an attribute, or how malformed markup was recovered. The main surprise is that the tree can differ from the apparent tag sequence because HTML parsing may implicitly close elements or otherwise repair invalid arrangements. The result describes parsed relationships rather than the original spelling of the source.

How the result is produced

1

From markup to hierarchy

When markup is entered, the viewer constructs the hierarchy represented by its elements. Start tags introduce elements, end tags close applicable elements, and attributes remain attached to their owning element. If markup is incomplete or malformed, HTML parsing rules determine the recovered relationships. The displayed result is therefore a parsed tree, not a syntax-highlighted or byte-for-byte copy of the input.

2

Reading the branches

Read each element relative to its displayed parent. Nodes listed beneath the same parent at the same level are siblings, while greater depth marks descent through another ancestor. Follow the branch from the first unexpected node upward to find the tag that changed containment. Source spaces and line breaks do not set DOM depth, so reindenting the input alone cannot change these structural relationships.

Good uses

  • Diagnosing a navigation menu whose links appear under the wrong list item after an omitted or misplaced closing tag.
  • Reviewing a copied component snippet to verify that wrappers, headings, buttons, and nested containers have the intended parent-child relationships before integration.
  • Checking whether class, id, data-*, and ARIA attributes landed on the intended elements after generating or transforming HTML.

Limits and checks

  • The viewer shows the parsed tree, not an exact source serialization. Quote style, attribute spacing, tag-name case, optional end tags, and other lexical details are not reliable things to infer from a DOM representation. Use the original text when those distinctions matter.
  • Fragment parsing depends on context. Table rows, cells, and option-related content are examples whose permitted placement is constrained. A standalone fragment may therefore produce relationships that differ from those created when the same characters are inserted into a specific element on a real page.
  • A plausible hierarchy is not proof that the HTML conforms to the standard, renders as intended, or is accessible. CSS can alter layout, scripts can later mutate the live DOM, and accessibility depends on semantics and computed relationships beyond a simple element tree.

Common questions

Why is an element under a different parent than I expected?

HTML defines error-recovery behavior for malformed or incomplete markup. Parsing can implicitly close elements or relocate nodes to produce a tree. Table-related markup and omitted end tags are common places to encounter this. The viewer reports the resulting parent-child structure, so inspect the source around the first branch that differs from your intended nesting.

Can this viewer confirm how the HTML will look or behave?

No. It can confirm parent-child relationships and show which attributes belong to each element, but a tree alone does not calculate CSS layout, paint order, or accessibility behavior. It can narrow a problem to structure. Visual rendering, computed styles, focus behavior, script-driven changes, and accessible names require additional browser inspection and testing.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools