I wrote an article about different ways how to hide code in Jupyter Notebook. According to my findings, there are several ways in which this can be done.
1. Hide all code in nbconvert
When exporting notebook with nbconvert
you need to add --no-input
in the command:
jupyter nbconvert --to html --no-input your-notebook.ipynb
2. Hide selected cells
You can hide selected cells by adding a tag hide_code
, like in the animation below:

The command that hide code only for selected cells:
jupyter nbconvert --to html --TagRemovePreprocessor.remove_cell_tags='{"hide_code"}' my-notebook.ipynb
3. Export to HTML with Mercury
The Mercury
is an open-source for sharing notebooks with non-technical users. It can hide code. It can also generate widgets for the notebook that are connected with variables in the code. The notebook export process is controlled with YAML header, below is the example YAML that hides the code:
---
title: My notebook
description: My amazing notebook with hidden code
show-code: False
---
The example notebook with YAML header:

The HTML (website) generated for the notebook with Mercury
:
