This notebook is part of the jupyter_format documentation: https://jupyter-format.readthedocs.io/.

Notebook format conversions with nbconvert¶

During the installation of jupyter_format (see Installation), so-called "entry points" for nbconvert are configured automatically.

You can convert .ipynb notebooks to .jupyter notebooks with

python3 -m nbconvert --to jupyter my-old-notebook.ipynb

To convert a .jupyter notebook to any format supported by nbconvert, just append -from-jupyter to the desired format.

For example, you can convert a .jupyter notebook to the traditional .ipynb format:

python3 -m nbconvert --to ipynb-from-jupyter my-new-notebook.jupyter

Or you can convert a .jupyter file to an HTML file:

python3 -m nbconvert --to html-from-jupyter my-new-notebook.jupyter

Same for slides-from-jupyter, latex-from-jupyter, pdf-from-jupyter etc.

But enough for the theory, let's try it with this very notebook, shall we?

In [ ]:
!python3 -m nbconvert --to ipynb-from-jupyter nbconvert.jupyter --output=my-new-notebook

Just to make sure it is actually using Jupyter's JSON format, let's peek at the beginning of the file:

In [ ]:
!head my-new-notebook.ipynb

Here's a link to the new file for your perusal: my-new-notebook.ipynb.

Now let's convert this back to .jupyter:

In [ ]:
!python3 -m nbconvert --to jupyter my-new-notebook.ipynb

Again, we take a peek:

In [ ]:
!head my-new-notebook.jupyter

And a link for closer inspection: my-new-notebook.jupyter.

Finally, let's try to convert this .jupyter file to an HTML page:

In [ ]:
!python3 -m nbconvert --to html-from-jupyter my-new-notebook.jupyter
In [ ]:
from IPython.display import IFrame
IFrame('my-new-notebook.html', width='100%', height=350)

And for completeness' sake, a link: my-new-notebook.html.