iLoveConverter
Categories 11 categories

The Jupyter Notebook (.ipynb) Format, Explained

iLoveConverter Team 3 min read

On this page

The .ipynb extension is Jupyter Notebook’s standard format. IPYNB stands for Interactive PYthon Notebook, though the name is outdated — Jupyter now supports over 100 kernels including Julia, R, Haskell and Go. An .ipynb file is a single JSON document that combines markdown cells, code cells, their executed outputs, metadata and configuration.

IPYNB file structure

Open any .ipynb in a text editor and you will see a JSON object with these top-level keys:

  • "cells" — ordered array of cells. Each cell is either "markdown", "code" or "raw".
  • "metadata" — notebook-level settings: kernelspec, language_info, widgets, execution count.
  • "nbformat" / "nbformat_minor" — schema version. Current major version is 4.

A code cell inside has:

{
  "cell_type": "code",
  "execution_count": 1,
  "metadata": {},
  "outputs": [ /* text, images, HTML, ... */ ],
  "source": ["print('Hello')\n"]
}

Outputs are embedded in the notebook file itself — that is why sharing an .ipynb often lets someone see the results without running the code.

.ipynb vs .py vs .Rmd

Aspect.ipynb.py.Rmd
Interleaved text + codeYesNoYes
Stores outputsYesNoOptional
Diff-friendlyNo (JSON is messy to diff)YesYes
Kernel / multi-languageYesPython onlyR + Python
Git-friendlyLimitedExcellentGood
Production-readyNoYesSomewhat

Notebooks are for exploration. .py scripts are for production. .Rmd is R’s version of the same interleaved idea, but with R as its primary language.

How Jupyter cells work

  • Markdown cells — written in Markdown, rendered as formatted text when you run the cell. They describe what you are doing.
  • Code cells — run interactively. Press Shift+Enter and the kernel executes the source, captures stdout/stderr and any rich display, and stores them in "outputs".
  • Raw cells — passed through without rendering; used for custom output formats like LaTeX preambles.

Every cell remembers its "execution_count" — the order it was run in the current kernel session. This is a hint of notebook state, but the execution_count values can be misleading if cells were run out of order.

Converting IPYNB

Jupyter ships with nbconvert for converting notebooks to many formats:

# To HTML (with inputs and outputs)
jupyter nbconvert --to html notebook.ipynb

# To PDF (via LaTeX or browser print)
jupyter nbconvert --to pdf notebook.ipynb

# To Markdown
jupyter nbconvert --to markdown notebook.ipynb

# To Python script (one .py per .ipynb)
jupyter nbconvert --to script notebook.ipynb

# Execute before exporting (recommended for reproducibility)
jupyter nbconvert --to html --execute notebook.ipynb

HTML and PDF export are what you share with non-technical collaborators. Markdown and script export are what you use when cleaning up an exploratory notebook into something committed to a repo.

Common problems

  • Out-of-order execution — cell 5 was run before cell 3; execution_count shows this. Use Kernel → Restart & Run All.
  • Large output bloats the file — clear all outputs before committing to git (Cell → All Output → Clear).
  • Binary outputs in JSON — PNG plots are base64-encoded inside the file, making it look enormous. Export HTML/PDF or clear outputs.
  • Collaboration pain via git — use nbdime to diff and merge notebooks, or store as .py in .ipynb_checkpoints form.

FAQ

Is .ipynb plain text?

Yes, it is valid UTF-8 JSON, so you can open it in any text editor. That said, it is not designed to be hand-edited — use Jupyter or VS Code’s notebook view.

Can a .ipynb run without Jupyter?

You can run one headlessly with jupyter nbconvert --execute, or open it with VS Code, PyCharm, or nteract. But you need a Jupyter-compatible kernel.

Are notebooks good for production?

Generally no. They are for exploration and prototyping. Production code should be .py scripts or modules, possibly generated from notebooks.

What is nbdime?

A git diff tool for notebooks. It shows cells, outputs and metadata changes separately, which normal git diff on JSON cannot do well.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: IPYNB (.ipynb) , MD (.md.markdown) , JSON (.json)