Collapse or folding code cell in Jupyter notebook


I know there is a collapse or folding function when I work in normal editor with .py in Pycharm.

However, it seems this function is not available in Jupyter notebook in Pycharm.

Is there any way that I can fold or collapse code in Jupyter notebook?



Yes, you can fold/unfold regions of your code in Jupyter cells the same way as it works in .py files. If you're talking about folding an entire cell, there's no feature for that, but you can use "fold selection" functionality to select and fold code in the cell.

If you mean some specific folding that doesn't work, please provide more information.


I can't find that in Pycharm's notebooks (jupyter) either. The only collapsable things sem to be functions, string literals and maybe something more but you can't decide what should be collapsable and the predetermined ones are inside a code cell. I'd like to collapse an entire section behind a tittle (an h1 or any level markdown tittle); that is much more useful in notebooks. 

I can do that in Collab at least, and I think it could be done at some point in Jupyter notebooks. I went to Collab just because of that though. I do see convenient to use notebooks inside Pycharm, but this is a big productivity deal... 

Any way you (Jetbrains) implement that anytime soon? 



Maybe if the outline (Structure panel) could directly move items, like Collab does, it wouldnt be super  necessary the previous collapse - although it'd still help to just visualize the important things in a glance 


any update on the collapsible feature?


The headers in Markdown cells can be collapsed and are visible in project structure. In code cells, you can create custom fold regions --

If that's not what you mean, could you please provide more specifics?


Hi, old thread but hoping for a reply.

I've been looking for a solution to collapsible headings in PyCharm Notebooks.

Unlike being able to only fold code within one cell, it would provide the option to fold/hide multiple code-cells and their output.

An example would be the Collapsible-headings extension for Jupyter Notebook.

and after collapsing/folding:

Extension link:


This would make it a lot easier to work in PyCharm Notebooks as they grow past 20-40 cells.


+1 also looking for this functionality in the jupyter notebook. need to do a lot of scrolling right now to move between cells with lots of code


+1 on this markdown heading fold/unfold feature. It would be really helpful to have this. 


There is a related feature request PY-65441 on that, please vote for it and feel free to comment. See if you are not familiar with YouTrack.


Please sign in to leave a comment.