Compare two blocks
This page compares two blocks of text or JSON and shows you which lines were added, removed or changed, highlighting the individual words inside a changed line. It needs JavaScript, because the comparison happens in your browser rather than on a server: that is the whole reason nothing you paste leaves the page.
Nothing to hand?
| # | Original | # | Changed |
|---|
How the comparison works
Lines are matched with Myers' diff algorithm (1986) —
the same one git diff uses. It finds the shortest edit
script, which is why a block you moved shows up as one deletion and one
insertion rather than as every line in between being marked changed.
Where a deletion and an insertion line up, the two lines are compared
again word by word so you can see the part that actually differs.
JSON mode
Ticking treat both sides as JSON re-prints each side with its keys sorted alphabetically and a consistent two-space indent before comparing. That removes the noise from key order and formatting, so what is left is a difference in the data rather than in how it was written. If either side is not valid JSON the tool says which line and column it gave up on, rather than silently comparing the raw text instead.
Where it stops
- 20,000 lines a side. Past that the tool refuses instead of locking up your tab.
- Very dissimilar files. Myers costs time proportional to the square of the number of edits, so when two files share almost nothing the tool stops and says so rather than hanging.
- Long lines are not word-diffed. The word comparison uses a table proportional to the two line lengths multiplied together; on a minified file that is not worth it, so those lines are shown as a plain change.
Privacy
There is no server side. The page makes no network requests once it has loaded, sets no cookies, stores nothing, and carries no analytics, no tag manager and no webfont. You can confirm all of that by reading the source of this page — it ships unbundled and unminified for exactly that reason.