Difficulty Editing Metadata Tags to Hide Cell Inputs and Outputs

I’ve consulted several forum and blog posts, and they all state that I can go into an individual cell’s metadata editor and add an appropriate tag to selectively hide a cell’s input or output.

For example, removing a cell’s input so that it won’t manifest either in the Jupyter-Lab environment or in an HTML/PDF report requires the tag,

{"tags": ["hide_input",]}

But whenever I do this, nothing happens. My Jupyter-Lab view doesn’t change. My HTML outputs still show the cells. No other blog post, article, or forum post I’ve seen so far either here or elsewhere can seem to explain to me what I’m missing.

Your title references ‘metadata’; however, you are editing the tags component for the cell.

The process can be demonstrated and tested in current JupyterLab. Click here to spin up a JupyterLab session using this repo for the content. The session is backed by MyBinder.org. The ‘index’ notebook will open. Click the blue bar next to the first code cell to hide the code cell. Save the notebook, and using the file navigator on the right open it in the editor by right-clicking on the file in the list, selecting open with ‘Editor’.

If you look in the editor, you’ll see cell the data for that cell is the following:

   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "jupyter": {
     "source_hidden": true
    "tags": []
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns"

The key part in there is:

"metadata": {
    "jupyter": {
     "source_hidden": true

The fact JupyterLab respects that setting can be demonstrated by clicking here where a JupyterLab session will open with the notebook I had saved already following what I suggested above. You’ll see the 2nd code cell, under 'Setup our imports, is the one visible when this notebook is reopened. (Notebook is here; however, you’ll note nbviewer, and github, doesn’t respect the hidden setting at this time).

This process of toggling settings and the fact JupyterLab respects the settings upon reopening is discussed here and here. You’ll want to pay special attention to the link at the end of that second listed link as it shows the proper syntax for the settings. You’ll note ‘hide_input’ does not appear on that page.

I believe you may have been finding information on the old classic notebook extension for the hide_code extension perhaps. I’m not sure what sources you are consulting as you don’t list them.

If you are using the editor to hand-edit the metadata direct in JupyterLab as you describe in your post, you’ll probably need to refresh the browser view in JupyterLab. It probably will note the change though in the backing code and let your reload with the new edit if you give it a chance.

There are (mis-specified) cells/<n>/metadata/source_hidden (and output_hidden, for code) which JupyterLab honors, but classic does not. As stated there, this is not intended for export mechanisms like nbconvert, and indeed, it doesn’t support any hard-coded value for tags for removing things, favoring a configuration-based approach. jupyter-book, nbsphinx and others have wildly-diverging plans for achieving this, and getting consensus is hard.

No other blog post, article, or forum post

Yep: the historic tribal knowledge of jupyter is stored in source code and maintained documentation itself, and the related GitHub issues and Pull Requests that made those come into being. If it’s not documented or in the code, it probably doesn’t exist.