Skip to content

Jupyter Notebook to HTML

Export a notebook as HTML without showing the source code so you can share results as a standalone page.

Terminal window
jupyter nbconvert --to html --no-input your_notebook.ipynb
# Safer when working inside a venv
python -m jupyter nbconvert --to html --no-input your_notebook.ipynb

For a new virtual environment, install nbconvert first. This is enough when the notebook already has saved outputs and you only need to export them to HTML.

Terminal window
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install nbconvert

Run the conversion through Python when you want to make sure the active venv is used.

Terminal window
python -m jupyter nbconvert --to html --no-input your_notebook.ipynb

For a site workflow that exports notebooks repeatedly, install nbconvert, jupyter, and ipykernel in the same venv.

Terminal window
python -m pip install nbconvert jupyter ipykernel

If the notebook does not already have saved outputs, execute it during conversion. The venv must also contain the notebook dependencies needed by the notebook itself.

Terminal window
python -m pip install nbconvert ipykernel
python -m jupyter nbconvert --to html --no-input --execute your_notebook.ipynb

Check that Python, pip, and jupyter all come from the active virtual environment.

Terminal window
which python
which pip
which jupyter
python -m jupyter nbconvert --version
# Expected paths should point into .venv:
# /home/example-user/projects/tools/nbconvert/.venv/bin/python
# /home/example-user/projects/tools/nbconvert/.venv/bin/pip
# /home/example-user/projects/tools/nbconvert/.venv/bin/jupyter
  • –to html - output format
  • –no-input - strips all code cells from the output, leaving only results and markdown
  • –execute - runs the notebook before writing the HTML output

The output file is placed in the same directory as the notebook with a .html extension. To write to a different location:

Terminal window
python -m jupyter nbconvert --to html --no-input your_notebook.ipynb --output-dir ./exports