Nimble Toolbox

Compare two texts

Paste a version into each box, or drop a file on each, and the comparison appears as you type. Both texts stay in this tab.

Texts to compare
Differences

The differences appear here once there is text on both sides.

How to use it#

  1. Paste the original version into the first box, or drop its file on the box. Open file does the same from a file picker.
  2. Paste or drop the version you want to compare into the second box.
  3. Tick ignore case or ignore whitespace if those differences do not matter to you.
  4. Switch the view between stacked and side by side, whichever reads better.
  5. Read the result, or copy it as a patch to paste into a review.

How the lines are matched up#

The hard part of comparing two texts is not spotting that they differ. It is working out which line in the second text corresponds to which line in the first, because once one line is inserted near the top, every line below it has shifted and a naive comparison reports the entire rest of the file as changed.

The answer is to find the longest sequence of lines that appears in both texts in the same order, and treat those as the unchanged ones. Everything else is then either a line the original had and the new version does not, or the other way round. A line that was edited shows up as both: the old wording marked as removed, the new wording marked as added directly underneath.

Identical stretches at the top and bottom are matched before any of that work begins, which is why comparing two copies of a long document with one paragraph changed is instant.

When to ignore case and whitespace#

Trailing spaces are the classic false positive. An editor that strips them on save will mark every line it touched as changed, burying the two lines you actually care about. Ignore whitespace treats a line as the same when only its spacing differs, including runs of spaces between words, so reindented code compares on its content.

Both options change the comparison and not the text. The lines are still shown exactly as you pasted them, so you can see that the spacing differs while the tool agrees the meaning has not. That distinction matters when the whitespace turns out to be the bug.

Reading the result#

Stacked puts everything in one column, with a removed line directly above the line that replaced it. Each row carries two line numbers, one for its position in the original and one for its position in the changed version. An added line has no number on the left because it did not exist there, and a removed line has none on the right.

Side by side gives each version its own column, with a line sitting opposite its counterpart. Where one version has a line the other does not, the empty cell is hatched, which is how an outright addition is told apart from an edit. This view suits a change with a lot of rewritten lines, because you read across rather than down.

In the stacked view the colour is backed by a marker in its own column, a plus or a minus, so the result still reads if colours are hard to tell apart or the page is printed in black and white. Side by side puts that information in the position instead: left is what you had, right is what you have now.

Within a line that was edited, the characters that differ carry a stronger wash of the same colour. A version number that went from 1.4.0 to 2.0.0 marks the two digits that moved rather than the whole line, which is the difference between reading a diff and searching one.

Copy patch gives you the same comparison in the format a patch file uses, with a leading plus, minus, or space on each line, whichever view is on screen. It pastes into a code review or an issue and stays readable there.

What it compares, and what it does not#

Lines are the unit. Change one word in a long paragraph and that whole paragraph counts as a line removed and a line added, because as far as the alignment is concerned the line differs. Within such a pair the characters that actually changed are then marked, so you are not left comparing two near-identical paragraphs by eye.

That suits code, configuration, logs, and CSV, where a line is a unit of meaning. For prose kept as one line per paragraph the line counts are coarse, though the character marks still point at the edit.

Windows, Unix, and old Mac line endings are all read as line breaks, so a file saved on one platform compares cleanly against the same file saved on another without every line coming back changed.

A file dropped on a box is read as text. UTF-8 is tried first, a byte order mark is honoured and then set aside, and a file that is not valid UTF-8 is read as Windows-1252, the older encoding such files usually use. When a file is read as anything other than UTF-8, the line under the box says which encoding was used. Word documents, PDFs, and spreadsheets are not plain text, so copy the text out of them and paste it instead.

Frequently asked questions#

Are my two texts uploaded anywhere?

#

No. The comparison runs in this tab as you type. Nothing is sent to a server, so two versions of a contract, a config file, or a patient list can be compared without any of it leaving your device.

What does ignore whitespace actually ignore?

#

Leading and trailing spaces and tabs on each line, and runs of spaces between words, which are treated as a single space. Two lines that differ only in spacing then count as unchanged. Blank lines are still lines, so adding or removing one is still reported.

Does it highlight the characters that changed within a line?

#

Yes. When a line was edited rather than added or removed outright, the exact characters that differ are marked on both sides, so changing 8080 to 8081 marks the last digit rather than the whole line. A line with no counterpart has nothing to compare against, so all of it counts as the change.

Should I use the stacked view or side by side?

#

Stacked is easier when the change is small, because the old and new wording sit on consecutive lines and you read straight down. Side by side is better when a lot has been rewritten, since each version keeps its own column. Both show the same comparison, and switching between them changes nothing but the layout.

Can I compare two files instead of pasting?

#

Yes. Drop one file on each box, or press Open file above a box to choose one. Any plain text file works, such as code, configuration, a log, or a CSV export, up to 10 MB each. The files are read in this tab and never uploaded, and once loaded their text can be edited in the box like anything pasted.

Can I compare two lists?

#

Yes, with one item per line. Lines are matched in order, so an item that moved counts as removed from one place and added in another. For two lists where order means nothing, sort both with sort lines first, and the lines marked as added or removed are then the items only one list has.

Can I compare two JSON files?

#

Yes, and it works best once both are laid out the same way. Two copies of the same data can differ in key order and spacing, and a line diff reports all of that as changes. Run each through the JSON formatter with the same indent and sorted keys, paste the results here, and the lines that differ are the values that really changed.

Can I compare two Word documents or PDFs?

#

Copy the text out of each one and paste it into the boxes. A Word document or a PDF stores its text in a binary format rather than as lines, so the file itself cannot be dropped in, but the text copied from it compares like any other. Formatting such as bold or a changed font is not part of the text, so only changes to the words show up.

Why does it say the texts are too different to line up?

#

Lining up two texts costs one comparison for every pair of differing lines, so two long documents with nothing in common would take long enough to make the tab stop responding. When that limit is reached the tool says so rather than freezing. Comparing a section at a time gets you a result.

Is the output a real patch file?

#

Copy patch produces the line markers a unified diff uses, which is what makes it readable in a code review. It has no file headers or hunk ranges, so it is for reading rather than for feeding to the patch command.