viewhack

Jupyter notebook viewer: read an .ipynb without Jupyter

Someone sent you an .ipynb and you have no Python, no Jupyter, or only a phone? Drop it here. You see the notebook as it was saved: Markdown and maths, highlighted code with each cell’s In [n], and the charts, pandas tables, printed text and errors it produced. No code is run.

The file is read by this tab only. It is not uploaded, and nothing in it is executed.

What it shows

What this cannot do

Useful to know about .ipynb files

What is inside an .ipynb
Plain JSON. A cells list holds every cell’s source as text; each code cell keeps its execution_count and an outputs list, where a chart is a base64 PNG (about a third larger than the picture) and a pandas table is both text/html and text/plain. metadata.kernelspec names the kernel, and nbformat 4 has been the layout since IPython 3 (2015). The older nbformat 3 put cells inside worksheets and had separate heading cells; this page reads both.
A worked example
The BSD-licensed test notebook test4.ipynb from the nbformat project reads as: nbformat 4.0, no kernel recorded, 9 cells (4 code, 5 Markdown), 4 with outputs. Its code cells ran as In [1], In [3], In [7], In [6], so it is flagged as run out of order, with numbers 2, 4 and 5 missing. Its largest output is a 12.2 KB PNG (a 520 × 67 logo); a %%javascript cell’s output is named and not run, and the <script> inside its HTML output is removed.
Why a notebook is huge
Almost always the outputs, not the code. Every inline chart is stored as base64 text, a printed DataFrame keeps both its HTML and its text form, and some libraries embed their whole JavaScript bundle (several MB) in one output. The “Largest outputs” table shows where the bytes are; clearing those outputs in Jupyter before sharing or committing to git shrinks the file.
The .py download
Each code cell follows a # %% In [n] line, the “percent” cell format that VS Code, Spyder and Jupytext understand, so the file still runs cell by cell. Lines starting with % (IPython magics such as %matplotlib inline) or ! (shell commands) are commented out, because plain Python cannot run them; a whole %%bash or %%time cell is commented out too.
Without uploading it
nbviewer shows only notebooks at a public web address, and GitHub only notebooks pushed to a repository. Here a private notebook, with its data in the outputs, stays on your computer. The HTML outputs are cleaned and drawn in a sandboxed frame that is not allowed to run scripts or load anything; the page checks after drawing that no notebook code ran.