Text/Code Diff Checker
A text and code diff checker that goes down to the word: edited lines show only the parts that actually changed, and the comparison exports as a unified .diff.
Drag & drop your file here, or
Drag & drop your file here, or
No comparison yet. Paste or drop both versions above, then press Compare. Every changed line is highlighted here side by side, and you can download the result as a .diff patch.
How to use
- Original holds the version you had, Changed holds the version you got. Paste into both boxes, or use the file picker sitting above each one.
- Read the status line before anything else. Added and removed count whole lines; changed counts lines that were edited in place rather than replaced outright.
- Switch between Split and Unified with the segmented control beside Compare, and drag the divider between the two input boxes when one side needs more room. Wrap turns soft wrapping on for both inputs and the result at once.
- Tick Ignore whitespace if the file was reformatted, then take the comparison away with Download .diff, or the copy button next to it for the patch text on your clipboard.
How the comparison works
Two versions of the same file, and the only question is what actually moved. Paste the old one into Original on the left, the new one into Changed on the right. The comparison redraws 200 ms after your last keystroke, so the Compare button is really only there for when you want it sooner than that. Matching lines get pinned in place first, which is what stops an insertion halfway down from painting everything below it red. A second pass then looks inside the lines that genuinely changed and marks the individual words. A status line in the button row keeps score, in the form +1 added · −0 removed · 1 changed.
Split view gives you two columns that scroll together. Unified stacks removals above additions in a single column, and that is what a phone loads into, anything 640px or narrower. Identical text nobody needs to read gets folded away: a run of eight or more unchanged lines collapses to three at each end, with a button in the gap telling you how many are hidden. Files can go in instead of paste, one per side, and the accept list carries twenty-two extensions plus anything the browser labels as text. Download .diff writes changes.diff with three lines of context around each hunk.
A four-line config, one edit and one addition
Original holds retries: 3, then timeout: 30, then host: staging.internal, then port: 8080. Changed holds the same four lines with retries: 5 in place of retries: 3, and a fifth line, tls: true, added at the bottom.
The status line comes back as +1 added · −0 removed · 1 changed. On the retries row only the 3 is struck on the left and only the 5 is marked on the right, because the text retries: is identical either side. The timeout, host and port rows stay plain. tls: true shows on the right with nothing facing it. Press Download .diff and the hunk header reads @@ -1,4 +1,5 @@.
Good to know
- Ignore whitespace only reaches the ends of a line. Re-indentation and trailing spaces stop counting, but spacing changed inside a line still registers, so const a = 1 against const a = 1 is a change either way. A blank line someone added is still an added line.
- A block that moved reads as a deletion in one place and an insertion in another. Move detection is not part of this.
- Word-level marking gives up past 3,000 characters on a single line, which in practice means minified JavaScript and single-line JSON get toned as whole lines. Two lines also have to be at least 40% similar by character pairs before they pair up at all, so a line you rewrote from scratch arrives as a removal plus an addition.
Frequently asked questions
Why did my rewritten line come out as a removal plus an addition?
Lines only pair up for word-level marking when they are still recognisably the same line. The test is a Dice coefficient over character pairs and the bar sits at 0.4. Rename a variable and you clear it easily. Replace the whole statement and you fall under, at which point one deletion and one insertion is the honest way to show it.
How large can the two sides get before it slows down?
Difference matters more than size. The line pass is Myers' O(ND) algorithm, so cost tracks the number of edits rather than the number of lines: two 10,000-line files differing in a dozen places finish quickly, while two files with nothing in common are the expensive case. Inside a single changed block there is also a cap, and past 100,000 candidate line pairs it falls back to matching by position.
What is the Expand 12 unchanged lines button doing?
Hiding context you did not ask for. Once eight or more consecutive lines are identical, three stay at the top of the run and three at the bottom, and everything between them collapses behind that button. The number on it is exactly how many lines are folded. Pressing it opens that one run and leaves the rest folded.
Will git apply take the downloaded .diff as it is?
Not without one small edit. The patch body is standard, with ---/+++ headers and @@ hunks, but the two filenames written into the header are placeholders: original.txt and changed.txt. Point those two lines at the real path in your working tree first. Copy patch puts the same text on the clipboard if you would rather paste it into a review.
Does it compare JSON by structure or just line by line?
Line by line, always. Swap the order of two keys in an object and you will see two changed lines here even though a parser would call the documents identical. The JSON Diff tool is the one that parses first and compares the tree.
One side ends with a newline and the other doesn't. Does that count?
No. A single trailing newline is normalised away before the comparison starts, so abc and abc followed by a line break come out identical. Blank lines inside the text are real lines and stay that way.
Can I compare two files without pasting their contents?
Each pane has its own picker above the text box, and dropping a file onto it loads the text and redraws straight away, no Compare press needed. One file per side. The accept list covers twenty-two extensions, from .md and .json through .py, .rs and .sql, and anything the browser labels as text goes in as well.
Missing something in Text/Code Diff Checker? Suggest a feature →
Tell someone who needs this.