Scenario
An embed snippet copied from a vendor dashboard works on one page and breaks on another. The markup arrived minified — one line, zero whitespace — so questions like "is the anchor inside or outside the span?" cannot be answered by reading it. Debugging minified HTML by eye leads to edits in the wrong element; indent it first and the tree answers most questions on its own.
Broken input
<div><span data-id="42">Hi</span><a href="/docs?x=1&y=2">Docs</a></div>
Goal
Use HTML Formatter to expand the snippet into an indented tree without changing what the markup means — attributes, entities, and query strings must all survive untouched.
Tool sequence
- Open HTML Formatter.
- Paste the snippet exactly as copied from the vendor dashboard.
- Format it and read the structure:
spanandaare siblings inside thediv, not nested in each other. - Verify the fragile parts survived:
data-id="42"still on the span, and the href's?x=1&y=2query string uncut. - Diff your page's version against the working page's version with Text / Code Diff Checker — with both formatted, the structural difference stands out immediately.
Checkpoint output
<div>
<span data-id="42">Hi</span>
<a href="/docs?x=1&y=2">Docs</a>
</div>
Two sibling elements inside a wrapper, attributes and query string intact. Any behavioral difference between pages is now checkable line by line.
Common mistakes
- Editing minified markup directly and closing a tag in the wrong place.
- Assuming a rendering difference is CSS before confirming the two pages even have the same tag tree.
- Breaking entities or query parameters while adding line breaks by hand —
&and&are not interchangeable mid-edit. - Formatting the snippet and forgetting the page might wrap it in a parent that changes its meaning.
Related tools and lessons
- Code Formatter - Format CSS, JS & TypeScript with Prettier.
- HTML to JSX Converter - Convert pasted HTML into JSX-friendly markup.
- HTML Entity Encoder / Decoder - Encode text as HTML entities or decode entities back to text.
- Related lesson: Clean Up a Snippet Before Reviewing It
- Related lesson: Convert HTML Into JSX Without Breaking Attributes