Is there a way to hide or toggle the visibility of code?

Double click the output cell instead

Like so

EDIT: From murrays comment: tutorial/WorkingWithCells: "To specify which cells remain visible when the cell group is closed, select those cells and double-click to close the group."


You can create a palette to show/hide all the input cells in the selected notebook.

CreatePalette[
    Column[{
        Button["Hide code", {
            NotebookFind[SelectedNotebook[], "Output", All, CellStyle];
            FrontEndExecute[FrontEndToken[SelectedNotebook[], "SelectionCloseUnselectedCells"]]
        }],
        Button["Show code", NotebookFind[SelectedNotebook[], "Input", All, CellStyle]]
    }]
]

I have to do this all the time. I only have an annoyingly manual way to solve this. On a mac, Alt-click on the cell marker on the right for an InputCell containing the code, this should select ALL input cells. Then go to the Cell -> Cell Properties menu at the top and unselect the Open item. All the input cells should hide. On the right there should still be tiny little input cell markers. To open them follow the same procedure and select the Open again.

The answer by "rm -rf" is great! Thanks.