Jupyter Notebook

Also known as: Jupyter

On this page 7

Jupyter Notebook is an open-source, browser-based interactive computing environment in which a document called a notebook combines executable code, its output, visualizations and formatted explanatory text. Among development tools in programming, it is the standard medium for exploratory data analysis, scientific computing, teaching and documenting reproducible experiments.

The project grew out of IPython in 2014, and the name refers to its original core languages: Julia, Python and R. Today, Jupyter supports dozens of languages through kernels, and the term Jupyter is often used for the whole family of tools, including the newer JupyterLab interface and hosted notebook services built on the same open file format.

How Jupyter Notebook executes code

Jupyter uses a client-server architecture with three parts. The browser front end displays the notebook, a notebook server manages files and sessions, and a separate process called the kernel actually runs the code. The front end sends each cell to the kernel over the Jupyter messaging protocol, which uses ZeroMQ sockets, and receives results to display under the cell.

Because the kernel is a long-running process, variables persist between cell executions. A user can load a large dataset once and then experiment with many analyses without reloading it. This stateful execution model is the main source of both the productivity of notebooks and their most common bugs.

The table below describes the components and their responsibilities.

ComponentRoleExample
Front endDisplays and edits notebooks in the browserClassic Notebook, JupyterLab
Notebook serverServes files, manages sessions and kernelsJupyter Server process
KernelExecutes code and returns resultsIPython kernel, IRkernel, IJulia
Messaging protocolCarries execute requests and outputsZeroMQ channels with JSON messages
Notebook fileStores cells, outputs and metadataAn .ipynb document
Main components of the Jupyter architecture

Cells and the .ipynb file format

A notebook is a sequence of cells, and each cell has a type that determines how it behaves. A notebook file uses the .ipynb extension and is a JSON document that stores the source of every cell, its outputs, the execution count and metadata such as the kernel name.

Cell typeContentWhen it is used
Code cellSource code sent to the kernelCalculations, data loading, plotting
Markdown cellFormatted text, equations, imagesExplanations, headings, documentation
Raw cellUnprocessed textContent passed directly to export tools
Cell types in a notebook

Outputs such as tables, images and interactive widgets are stored inside the file, often as base64-encoded images. This makes a notebook self-contained and readable without rerunning it, but it also makes files large and produces noisy version control diffs. Tools such as nbstripout remove outputs before a Git commit, and Jupytext pairs a notebook with a plain script for cleaner review.

The nbconvert tool exports notebooks to HTML, PDF, slides or plain scripts, while IPython magic commands such as %timeit and %matplotlib inline add conveniences specific to the Python kernel.

Jupyter Notebook compared with JupyterLab and IDEs

Jupyter Notebook is one of several ways to work with notebook files, and it differs from a full integrated development environment in purpose more than in capability. The classic interface focuses on one document at a time, while JupyterLab offers a multi-panel workspace, and editors such as Visual Studio Code can open .ipynb files natively.

ToolStrengthWeaknessBest fit
Jupyter NotebookSimple, focused interfaceLimited project navigationExploration, teaching
JupyterLabTabs, file browser, terminals, extensionsMore complex interfaceDaily data science work
Visual Studio CodeNotebooks plus debugger and GitHeavier setupMixed notebook and module development
Traditional IDE with scriptsRefactoring, testing, packagingNo inline rich outputProduction software
Notebook interfaces and traditional development tools

Since version 7, the classic Jupyter Notebook interface is built on JupyterLab components, so both share extensions and the same server, while keeping the simpler single-document layout.

Typical uses and good practices

Notebooks excel when code, results and reasoning must be read together. Common uses include data cleaning and visualization, prototyping machine learning models, course materials, research supplements and reproducible reports. Hosted services such as Google Colab and JupyterHub deployments let teams run notebooks on shared servers or GPUs without local installation.

To keep notebooks reliable, experienced practitioners follow a few disciplined habits, summarized in the decision table below.

SituationRecommended practiceReason
Before sharing resultsRestart kernel and run allConfirms the notebook runs top to bottom
Code reused in several notebooksMove it into a Python moduleEnables testing and single maintenance
Notebook kept under GitStrip outputs or pair with JupytextProduces readable diffs
Dependency-sensitive analysisPin packages in an environment fileMakes results reproducible
Scheduled reportingRun with papermill or nbconvertExecutes notebooks without a browser
Good practices for maintainable notebooks

Limitations and common pitfalls

The best-known weakness of notebooks is hidden state. Cells can be executed in any order, deleted after running or edited without rerunning, so the visible document may not match the values held in the kernel. Studies of public notebooks have repeatedly found that many cannot be rerun successfully from top to bottom.

  • Out-of-order execution, visible as nonsequential execution counts, which hides dependencies between cells.
  • Large embedded outputs that inflate files and expose sensitive data when shared.
  • Long notebooks used as production code, which resist testing and code review.
  • Missing environment information, so results differ on another machine.
  • Security risk from opening untrusted notebooks, because running cells executes arbitrary code.

For these reasons, many teams treat notebooks as an exploration and communication layer, while moving stable logic into versioned, tested modules.

Stripped to the essentials

A Jupyter notebook is like a lab journal that can run code. You write a small piece of code in a box and run it. The answer appears right below, as a number, a table or a chart. Notes and results stay side by side.

You can then explain what you found in normal text. Others can read the whole story or rerun it themselves. The main rule is simple: run the boxes in order, so the results stay correct.

Where it is applied

A data analyst at a regional hospital network is asked why emergency department waiting times rose during the winter. She opens a Jupyter notebook in JupyterLab, loads two years of anonymized visit records with pandas and plots arrivals by hour and weekday directly under the code.

Within an afternoon, the charts reveal that delays cluster between 6 p.m. and 10 p.m. on Mondays, when staffing is lowest. She adds Markdown cells that explain each step, restarts the kernel and runs all cells to confirm reproducibility, then exports the notebook to HTML for the management team. The result is a staffing change backed by transparent analysis, and the same notebook is rerun monthly with papermill to track whether waiting times improve.