Hidden cells are not hidden in nbviewer

Hiding cells in Jupyter Lab is a great feature, but when I view the notebook with (some) hidden cells on nbviewer they are not hidden. Is there a workaround? Am I doing something wrong? Or is this something the nbviewer developers are working on?

I canot speak to most of those questions. Hopefully someone with more insight will also respond.
I do know using MyBinder to open updated JupyterLab cells it now respects the hidden nature. I’m not sure for nbviewer.

As for a workaround if you need something for now, Peter Parente has some javascript posted to enable hiding input cells. I wonder if it adaptable to your needs?

Related to the workaround effort: [Solved] Javascript How to hide code from cells in ipython notebook visualized with nbviewer? - Code Redirect

1 Like

It would be nice if JupyterLab, JupyterBook and nbconvert (and thus nbviewer) all converged on a common way of hiding and removing cells, inputs, and outputs. The current situation is very confusing for users - I saw the confusion of these several times.

JupyterLab uses jupyter.outputs_hidden, jupyter.inputs_hidden and collapsed metadata. This complies with nbformat specification.

"metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true,
     "source_hidden": true
    "tags": []

Jupyter Book uses tags for hiding and removing cells/inputs/outputs. Hiding works as in JupyterLab - the cell (/cell input/cell output) gets collapsed but it can be uncollapsed manually:

    "tags": [

Removing removes the cell from display altogether:

    "tags": [

NBconvert supports use of tags for removal of cell/input/output, but none are configured by default (and configuration seems to require users to write Python code, which I don’t think is a good solution for cross-language tool). The documentation suggests tags different than those used by Jupyter Book (hyphen vs underscore*):

  • remove_input
  • remove_output
  • remove_cell

* but I am not actually sure because the Jupyter Book docs elsewhere suggest using remove_cell and apparently both should work in Jupyter Book (Update hiding.md by niekveldhuis · Pull Request #1398 · executablebooks/jupyter-book · GitHub) - but it seems to be confusing to users as well.

CC @jasongrout @choldgraf - what do you think? Should nbconvert remove hidden cells by default? Should Jupyter Book use jupyter metadata instead of tags? Should nbformat support a distinction between hiding and removing cells? Was there a prior discussion on this?


Thanks. This is good information. It would be nice if these different part (JupyterLab, JupyterBook, nbconvert, nbviewer) all use the same api for hiding cells. What is the best move forward? Open an issue on github? But where, since JupyterLab, JupyterBook, nbconvert, nbviewer are not all at the sam place, are they?

Let’s wait for others I mentioned to reply - maybe some discussions already happened :slight_smile: