HTML Compare Tool
Side-by-Side Diff · DOM Analysis · Size Comparison

Paste two HTML documents to see a side-by-side diff with syntax highlighting, byte size comparison, DOM node counts, and top tag frequency breakdown.

Side-by-side diff Syntax highlighting DOM analysis No login

HTML Compare Tool

Paste original HTML on the left and modified HTML on the right. Added lines are highlighted green, removed lines red.

View:
Original HTML 0 lines · 0 bytes
Modified HTML 0 lines · 0 bytes
+ 0 added − 0 removed = 0 unchanged 0 → 0 bytes

HTML Diff Guide

How to read and use HTML diffs effectively for code review and debugging.

Reading the diff output

Green lines with + prefix are lines added in the modified version. Red lines with - prefix are lines that existed in the original but were removed. Grey/unchanged lines provide context around changes. The line numbers on each side correspond to the original (left) and modified (right) documents independently.

Common HTML diff use cases

Comparing CMS output before and after a theme update. Verifying that a refactor didn't change the rendered structure. A/B testing page variants to measure structural differences. Code review of HTML templates. Checking that a minifier preserved all content. Debugging unexpected rendering changes after a deployment.

Side-by-side vs unified diff

Side-by-side diff shows both versions simultaneously with aligned lines — easier to read for small changes in long files. Unified diff shows a single stream with +/- prefix markers — more compact, standard format used by git diff, patch files, and code review tools. Use unified format when sharing diffs in text or email.

HTML-specific comparison tips

For the cleanest diff, format both HTML files consistently before comparing — whitespace differences create noisy diffs that obscure real changes. Most minified HTML will show one giant line change versus formatted HTML. Consider using the Format button to normalize whitespace before comparing CMS-generated HTML against hand-written HTML.

HTML Size & Performance

Why HTML size matters for performance and what the DOM analysis numbers mean.

HTML size and page speed

Raw HTML file size affects download time — especially on mobile connections. Every extra kilobyte adds transfer time. Gzip typically compresses HTML to 20-30% of its original size, so a 100KB HTML file becomes ~25KB over the wire. However, the browser still needs to parse the full uncompressed HTML, which takes CPU time proportional to the file size. Keeping HTML lean improves Time to First Byte (TTFB) and First Contentful Paint (FCP).

DOM node limits

Google recommends keeping the DOM below 1,500 nodes (ideal under 800). Excessive DOM size increases memory usage, extends style recalculation time, and causes layout thrashing. Each node in the DOM tree takes roughly 100-200 bytes of memory. A DOM with 5,000 nodes uses ~500KB-1MB of memory just for the tree structure. The DOM analysis panel above shows total element count, depth indicators, and tag frequency breakdown for both HTML versions.

HTML Tools

HTML Compare – FAQ

How do I compare two HTML files?+
Paste the original HTML in the left pane and the modified HTML in the right pane, then click Compare. The tool uses the LCS (Longest Common Subsequence) algorithm to find the minimal set of changes between the two versions. Added lines are highlighted green, removed lines red, unchanged lines stay neutral. Switch between Side-by-Side and Unified views using the buttons above the diff output.
Is my HTML data sent to any server?+
No. All comparison, diff computation, and DOM analysis runs entirely in your browser using JavaScript. Your HTML content never leaves your device. This makes it safe to compare HTML containing sensitive data, internal templates, or proprietary code. You can verify this by checking the Network tab in browser DevTools — no requests are made when you click Compare.
Why does whitespace-only change create so many diff lines?+
Line-based diff treats any whitespace difference as a changed line. If you're comparing minified vs formatted HTML, or HTML from two different editors with different indentation settings, nearly every line will show as changed. For cleaner diffs: paste both versions into a formatter first to normalize whitespace, then compare. Alternatively, use the "ignore whitespace" option in tools like diffchecker.com — this comparer shows the raw line diff for accuracy.
What is the DOM node count and why does it matter?+
The DOM node count is the total number of HTML elements in the document. Google Lighthouse warns when DOM size exceeds 1,500 nodes with a "critical" flag at 800+ nodes. Large DOMs increase memory consumption, slow down CSS selector matching (especially on complex pages), and cause longer layout recalculation times when JavaScript modifies the DOM. The DOM analysis panel above shows element counts, script counts, and the most-used tags in each HTML version.