Notebooks are amazing for research! And tutorials 😉
The .ipynb format (JSON) may be a bit verbose but overall it is simple, robust and well documented.
Jupytext: edit1 your notebooks as .py files2
Content is almost what you typed!
Tip
pre-commit, ruff, typing etc. just workTip
Text only notebooks are a good fit for
py:percent format)In general you want paired notebooks. A paired notebook is made of two files:
notebook.ipynb is your usual notebooknotebook.py is the text versionOpen either file in Jupyter (they are the same document).
Both files get updated when you save the notebook.
Open notebook.py in your IDE and edit it. Then re-open the notebook in Jupyter (or reload it), and you will see the edits!
Input cells are loaded from the .py script
Output cells are loaded from the .ipynb file.
Tip
To force the synchronization outside of Jupyter, use either jupytext --sync, our pre-commit hook, or the community-maintained plugins for VIM and VS Code
pip install jupytext or conda install jupytext -c conda-forgeNow .py and .md files have a notebook icon, and you get a Jupytext sub-menu in Jupyter 🎉
Pair one notebook using the Jupytext Menu:

Pair all notebooks in the current and child folders with a jupytext.toml file containing e.g. formats="ipynb,py"
Create text only notebooks with the New Text Notebook menu.

Open existing text notebooks with a right click1
Jupytext is compatible with the following stacks
# %% scripts, sync through plugin.qmd) and RStudio (.Rmd), PandocJupytext: Text notebooks that you will love, by Marc Wouts. PyData London, June 8, 2025