Mar 01 2022 · Piotr Płoński

The ipynb Jupyter Notebook File Extension

Jupyter Notebook File Extension bannerThe *.ipynb file extension is used for computational notebooks that can be open with Jupyter Notebook. The Jupyter Notebook was formerly named IPython Notebook. The extension *.ipynb is from letters IPython Notebook. The IPython was developed as a command shell for interactive computing in Python programming language. It offers introspection, rich media, shell syntax, tab completion, and history.

What is inside ipynb file?

You can open the *.ipynb file with any text editor. The file contains the JSON object. It has information about input code, that is formed in cells, and information about code execution result (the output).

Below is the example notebook.ipynb file presented as plain text:

{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d343b0f6",
   "metadata": {},
   "source": [
    "## Hello world!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2c787a5c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is ipynb file\n"
     ]
    }
   ],
   "source": [
    "print(\"This is ipynb file\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "venv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

Please note that there are cells in the JSON. Each cell could be the Markdown, plain text (raw cells) or Python code. The code cell has outputs which represent the execution result. The file containes the metadata information about kernel and language that was used to create the notebook. Let's look closer how the file will look like in the Jupyter Notebook application:

Notebook in Jupyter

The Jupyter application reads the JSON file and present it in the human readable format. It is worth to mention that Markdown text can be mixed with Python code. This gives huge flexibility for writing computational documents and reports.

How to open ipynb file?

As you see in previous paragraph the ipynb file can be opened even in a text editor, but what applications can be used to open the file in human friendly format?

The list of applications that can render the notebook and allows the edit:

  • Jupyter Notebook
  • Jupyter Lab
  • Jupyter Lab Desktop
  • VS Code with Jupyter Extension
  • PyCharm and DataLore

The list of cloud based services for opening the notebook (you can upload the notebook to the service to render/edit it):

  • CoCalc
  • Deepnote
  • Kaggle Kernels
  • Google Colaboratory

It is important to mention that there are also services that allow to only render the notebook. The most popular is nbviewer. It can render any notebook that is available online.

If you add ipynb file to the GitHub repository, the GitHub website will render the notebook.

Convert ipynb to other formats or web app

The ipynb files can be converted into many formats. They can be easily converted to HTML or PDF files (directly in Jupyter application).

There is a package jupytext that can be used to convert ipynb to plain Python files (.py).

If you would like to share the ipynb as interactive web app, then the Mercury framework can be a good choice. It allows to convert a notebook to web app. Just add YAML header as a raw cell in the notebook to add widgets for the notebook.

Become a Data Science wizard, today!

Forget about Python problems, just do your work.

MLJAR Studio