nbview

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

  1. Open nbview’s compare page, or choose Compare in the toolbar of any notebook you already have open.
  2. Paste a link to each notebook, pick two .ipynb files 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.
  3. 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

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

ToolWhere it runsWhat it needs
nbdimeOn your machine, as a Python package, CLI or JupyterLab extensionThe notebooks already downloaded, plus a Python install
ReviewNBAs a GitHub App, on pull requestsInstall access to the repositories you want to review
nbviewIn the browser, given two links or two filesNo install or app; public notebooks need nothing, private ones a read-only token
Compare two notebooks View .ipynb files from GitHub

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.

Private repos

To open notebooks from private repos, use a fine-grained token with Contents: Read-only access to those repos. A classic token with no scopes works for public repos and raises the folder-browsing limit.

Folder browsing allows 60 requests an hour without a token and 5,000 with one; opening public notebooks does not use that limit. The token is stored in this browser only and sent only to api.github.com. The privacy page lists everything nbview keeps.

Create a fine-grained token

Compare

Compare at with another version of it, or with a different notebook.

Embed this notebook

Paste this into any page that allows iframes. The notebook is fetched and drawn by the reader’s browser, so nothing is uploaded, and the frame posts its height to the host page for optional auto-sizing.

Keyboard shortcuts

/
Search on the home page, or Find in a notebook
j / k
Next or previous cell in a notebook, or change in Compare
c
Hide or show code
o
Hide or show outputs
t
Open or close the Contents menu
l / w
Toggle line numbers or wrap lines
?
Show or close these shortcuts
Esc
Close a dialog, menu or Find