Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to effectively diff a notebook with another version of it? This is usually needed/encountered in revision control, but can be generally useful. What i currently do is disable notebook history, use less styling, and diff them as text files.

share|improve this question
Some relevant answers here. – b.gatessucks Nov 8 '12 at 17:12
Yeah, I'd say it's a duplicate. – R. M. Nov 8 '12 at 17:20
This might be useful for you: – Szabolcs Nov 8 '12 at 18:07
up vote 8 down vote accepted

The old AuthorTools` package has a NotebookDiff function. You can open the package's documentation like this:

NotebookOpen@FileNameJoin[{$InstallationDirectory, "AddOns", "Applications", 
 "AuthorTools", "Documentation", "English", "AuthorToolsGuide.nb"}];

This function is also included in the undocumented NotebookTools` context (in version 8 at least). You can simply evaluate


which will pop up a file chooser dialog, or you can pass the two notebooks to it as an argument (either file names or notebook handles, such as the ones returned by Notebooks[]). Please also see this answer of mine.

Access to this diff functionality is included in several of the Tortoise version control clients on Windows. TortoiseSVN and TortoiseHg are both set up by default to diff Mathematica notebooks this way (see here).

share|improve this answer
To be clear: the output of NotebookTools`NotebookDiff[] should be sent to CreateDocument[], i.e., CreateDocument@NotebookTools`NotebookDiff[]. This will render the diff output in a nice readable form. – Jess Riedel Dec 18 '15 at 17:13

Copy as Input Text and paste into Quick Diff Online works very well. As previously described here.

share|improve this answer

It might be possible to use some of the techniques that the experts here provided when I asked this question before.

notebook1 = 
   Import["/Users/cormullion/Desktop/hex-chart.nb", "Plaintext"]];
notebook2 = 
   Import["/Users/cormullion/Desktop/hex-chart-a.nb", "Plaintext"]];
sa = SequenceAlignment[notebook1, notebook2];
  sa /. {a_, b_} :> {Style[a, Red], "(", Style[b, Green], ")"}]

giving something looking like this:

dodgy screen grab

Red shows deletions, green shows additions. Perhaps the parentheses are not ideal for this application...! You can tell that I changed the base from 16 to 12 in the second version of the notebook. Although I used this solution, there's a better built-in but undocumented one found by ace spelunker @rm-rf which you could play with.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.