Compare two Jupyter notebooks
nbview shows what changed between two .ipynb files, cell by cell, in the browser. Neither notebook is uploaded: each one is read from GitHub, a gist or a link by the browser that is showing it.
How to compare
- Open nbview’s compare page, or choose Compare in the toolbar of any notebook you already have open.
- Paste a link to each notebook, pick two
.ipynbfiles from your disk, or mix the two: a link on one side and a file on the other. The two can sit in different repositories, branches or folders. - Read the diff. Each changed cell is shown with the version it came from, and a swap button above it flips the two sides.
A link can carry the comparison itself, so a review comment or a class note can point at it. The # is part of the address: the viewer routes on it, so a link without one lands on the home page.
/#/compare/github/{owner}/{repo}/{older}...{newer}/{path}.ipynb
/#/compare/links/{first-notebook-link}/{second-notebook-link}
Earlier versions, and renamed files
Compare on a GitHub notebook lists that file’s own commits, so the notebook can be diffed against the version from three runs ago without leaving the page. The list is built from the file’s current path, because that is what GitHub’s commits API reports for a path, and a path does not follow a rename: after a notebook is moved or renamed, the list starts at the rename. The versions before it are still in the repository, so open the notebook at its old path and commit, and use the two-notebook comparison with that link on one side and the current notebook on the other.
What the diff shows
- Cells that were added, removed or modified, kept in their original order so the story of the notebook still reads top to bottom.
- Line-level changes inside a modified code cell, rather than the whole cell marked as replaced.
- Changed outputs, once Show output changes is pressed. A cell whose code is identical but whose printed result, table, chart or traceback differs then shows up as a change, which is often the only evidence that a run went differently.
- Markdown edits, next to the code edits, in the same view.
Private repos, and notebooks on your disk
Files you choose from your disk are read in the page and never leave the browser. Private repositories work once a fine-grained GitHub token with Contents: Read-only is saved: the token stays in this browser and is sent only to api.github.com.
A link and a file can be compared with each other, which is how a notebook downloaded from Colab is checked against the version in its repository. That comparison has no address to share, because the file stays on your disk. A Colab or Google Drive link on its own needs a Google sign-in, so nbview asks for the downloaded file instead.
How this compares with other notebook diffs
| Tool | Where it runs | What it needs |
|---|---|---|
| nbdime | On your machine, as a Python package, CLI or JupyterLab extension | The notebooks already downloaded, plus a Python install |
| ReviewNB | As a GitHub App, on pull requests | Install access to the repositories you want to review |
| nbview | In the browser, given two links or two files | No install or app; public notebooks need nothing, private ones a read-only token |
nbview is a free, open-source notebook viewer. It is an independent project and is not affiliated with Project Jupyter or nbviewer. Open the viewer, read the README, or see what changed, or read the privacy note.