HTML Diff: Compare Two HTML Files Online
Paste two versions of some HTML and this tool shows you exactly what’s different: lines that were added, lines that
were removed, and the words that changed inside a line. You can line them up side by side or read them as one
list, skip the differences that don’t matter (like indentation or attribute order), and preview both pages next to
each other. It all runs in your browser, so your code isn’t uploaded anywhere.
What is an HTML diff?
A diff is a list of the differences between two versions of a file. The name comes from the old Unix
diff command, and it’s the same thing you see in a pull request on GitHub or in
git diff. An HTML diff does that for HTML: it compares the code line by line and tells you what
changed, so you don’t have to read two long files and play spot the difference.
When would you use one? A few real situations:
- Checking what a CMS changed. You edited a page in WordPress or another editor, and now the layout is
off. Compare the HTML from before and after to see which tags or classes the editor added.
- Reviewing a template update. A theme or a component library shipped a new version. Diff the old
and new markup to see what you need to copy into your own changes.
- Proofing an email edit. Someone tweaked the newsletter template. A diff shows if they only changed
the text, or also broke a table or a link.
- Finding why two pages behave differently. The page works on staging and not on live? Save both
pages’ source and compare them.
How to use it
Step 1 Add both versions
Paste the old HTML in the Original box and the new HTML in the Changed box. You
can also click the upload button on a box to open a file, or drag a file onto it. Got them the wrong way round?
Click Swap. To try it first, click Sample: it loads two versions of a small café
page with a new heading, a moved attribute, an added list item, a changed class and a removed paragraph.
💡 Comparing two live pages? Open each one, press Ctrl+U (Cmd+Option+U on a Mac) to see its source, and copy that
in.
Step 2 Read the differences
The result updates a moment after you stop typing. The bar at the top sums it up, for example “3 lines added, 1
removed, 2 changed”. Use the arrow buttons next to it to jump from one change to the next. Long stretches that
didn’t change are folded away; click “Show 24 unchanged lines” to open one up.
- Side by side: the two versions in two columns, with matching lines on the same row.
- Unified: one column, like
git diff. Removed lines start with −, added lines with
+. It’s easier to read on a phone.
- Preview: both pages drawn next to each other, with scripts turned off.
Step 3 Hide the noise
Tick the options above the result to skip differences that don’t change the page, like indentation or the order
of attributes. They’re explained below, with examples.
Step 4 Copy or download the diff
Copy puts the differences on your clipboard as a unified diff (the format git diff
and diff -u use), ready for a pull request, a ticket or a chat. Download saves the
same text as a .diff file. If you opened files, the diff uses their names. Pasted code is called
index.html, so change that name in the first two lines if your file is called something else.
Reading the colors
Red is the original and green is the changed version. Here’s a real result from the tool for a small menu. It says
1 line added, 1 removed, 1 changed:
Example diff| 1 | <ul class="menu"> | 1 | <ul class="menu"> |
| 2 | <li>Tea</li> | 2 | <li>Tea</li> |
| 3 | <li>Coffee</li> | 3 | <li>Coffee</li> |
| | 4 | <li>Juice</li> |
| 4 | </ul> | 5 | </ul> |
| 5 | <p>Cash only.</p> | | |
| 6 | <p class="note">Open daily from 8 am.</p> | 6 | <p class="note">Open every day from 7 am.</p> |
- Green line, gray hatch on the left: added. “Juice” is new.
- Red line, gray hatch on the right: removed. “Cash only” is gone.
- Red and green on the same row: a changed line. The darker parts are
the exact words that changed: “daily” became “every day”, and 8 became 7.
- White: the same in both.
The options, and why they matter
Two pieces of HTML can look different as text and still draw exactly the same page. Without these options, a diff
would be full of changes you don’t care about. Each one tells the tool to skip one kind of difference.
What each option ignores, with an example | Option | What it skips | These count as the same |
| Ignore whitespace | Indentation, tabs versus spaces, extra spaces inside a line and blank lines. On by default. | <p>Hello</p> <p>Hello</p> |
| Ignore case | Upper and lower case, in tags and in text. Old HTML often has capital tags. | <DIV CLASS="box"> <div class="box"> |
| Format both first | How the code is laid out. Both sides are pretty-printed the same way before they’re compared. | <ul><li>Tea</li></ul> <ul>
<li>Tea</li>
</ul> |
| Ignore attribute order | The order of attributes inside a tag. | <img src="cat.jpg" alt="Cat"> <img alt="Cat" src="cat.jpg"> |
| Ignore comments | Everything inside <!-- -->. Lines that only hold a comment are skipped. Conditional comments like <!--[if mso]> stay, because email code needs them. | <p>Hi</p> <!-- new intro -->
<p>Hi</p> |
Format both first: compare minified with indented HTML
This is the one that saves the most time. If one version is minified (all on one line) and the other is nicely
indented, a plain line diff can’t match anything, because the lines are completely different. Format both first
runs both sides through the same formatter as our HTML Formatter, so the tags end up
on the same lines and only the real change is left.
Original (minified):
<nav><ul><li><a href="/">Home</a></li><li><a href="/menu">Menu</a></li></ul></nav>
Changed (indented, one word added):
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/menu">Our menu</a></li>
</ul>
</nav>
Format both first off: 5 lines added, 1 changed. On: 1 line changed.
💡 With this option on, the line numbers in the result are for the formatted code, not your input. Copy and
Download give you a diff of the formatted code too.
Ignore attribute order
The browser doesn’t care in which order attributes come, but people and tools shuffle them all the time. A CMS
might write class before href, and your editor the other way round. This option sorts
the attributes of each tag before comparing.
Original:
<a href="/menu" class="btn">See the menu</a>
Changed:
<a class="btn" href="/menu">See the menu</a>
Ignore attribute order off: 1 line changed. On: No differences.
💡 It sorts whole attributes, not the words inside them, so class="btn big" and
class="big btn" still show as a change. It also works per line: if a tag is split over several
lines, turn on Format both first as well.
Ignore whitespace, case and comments
Ignore whitespace is on by default, because indentation almost never changes how a page looks.
Turn it off when spaces matter, for example inside <pre> or in a text where a double space is
the bug you’re looking for. Ignore case helps with old HTML written in capitals.
Ignore comments is handy when one version has notes or build markers like
<!-- generated 2026-11-24 --> that you don’t want in the way. It leaves two things alone:
text inside <script> and <style> (a <!-- there is part of
the code, not a comment), and Outlook’s conditional comments like <!--[if mso]>, which change
what an email shows.
Skipped lines stay in the result in gray, so the line numbers still match your files. They just don’t count as
changes.
What it can and can’t tell you
✅ What it shows
- Every line that was added, removed or changed in the code, with the words that changed.
- Changes in tags, attributes, classes, text, inline styles and scripts.
- Both pages next to each other in the Preview tab, so you can check the look yourself.
🙈 What it can’t
-
It compares text, not how the page looks. A one-word change can move a whole layout, and a big code change can
look the same on screen.
-
Content added by JavaScript after the page loads isn’t in the HTML you paste, so it isn’t compared. Neither is
CSS from separate files.
-
A block of code that moved shows up as removed in one place and added in another. Only you know it’s the
same block.
- It doesn’t check if the HTML is valid. Use the HTML Validator for that.
Related tools
Frequently Asked Questions
How do I compare two HTML files?
Paste the old version in the Original box and the new version in the Changed box, or click the upload button on each box to open a file. You can also drag a file onto a box. The differences show up on the right a moment later: removed lines in red, added lines in green, and the exact words that changed in a darker shade.
Is my HTML uploaded anywhere?
No. The comparison runs in your browser, so your code never leaves your computer. That makes it fine to compare a page that isn’t live yet, or an email template with real customer names in it.
Why does it say every line changed when I only changed one thing?
Usually one side is minified (all on one line) or indented differently, so the lines don’t line up at all. Tick Format both first. Both sides get pretty-printed the same way before they’re compared, and only the real change is left. Ignore whitespace helps too when the only difference is tabs versus spaces.
What does Ignore attribute order do?
It sorts the attributes of each tag before comparing, so <img src="logo.png" alt="Logo"> and <img alt="Logo" src="logo.png"> count as the same. The browser doesn’t care about attribute order, but CMS editors and templates often shuffle them. It works on tags that sit on one line; turn on Format both first if your tags are split over several lines. The order of class names inside class="..." still counts, because that’s one value.
What do the colors mean?
Red is the original, green is the changed version. A red line with an empty space next to it was removed, a green line with an empty space next to it was added, and a red and green line side by side is a line that changed. Inside a changed line, the darker red and green mark the exact words. Gray lines were skipped because of your options, like a blank line with Ignore whitespace on.
Can I save the differences?
Yes. Copy puts them on your clipboard as a unified diff, the same format git diff and diff -u use, and Download saves a .diff file. You can paste it in a pull request, a ticket or a chat, and tools like git apply and patch can apply it. It uses the names of the files you opened; pasted code is called index.html, so change that name in the first two lines if your file has another one. With Format both first on, the diff is of the formatted code.
Does it show how the pages look different?
Not as a highlight. It compares the code, line by line. The Preview tab shows both versions next to each other so you can look for visual changes yourself, with scripts turned off. A CSS change in a separate file, or content added by JavaScript after the page loads, won’t show up here, because it isn’t in the HTML you pasted.
How big can the files be?
Each side can be up to 50,000 lines or 3 MB. A few thousand lines usually compare in well under a second. When two versions are almost completely different, some parts may show as fully removed and added instead of line by line, and the summary tells you when that happens.