How to Hide Code in a Jupyter Notebook PDF (Show Only Outputs)
Export a Jupyter notebook to PDF without code cells: use nbconvert --no-input, cell tags like remove_input, or one switch in ipynbtopdfscanner.
Quick answer: With nbconvert, add --no-input: jupyter nbconvert --to pdf --no-input notebook.ipynb. To hide only some cells, tag them remove_input or remove_cell. In ipynbtopdfscanner, switch off Show code, or tap a single cell and choose Hide this cell.
Hide all code with nbconvert
jupyter nbconvert --to pdf --no-input notebook.ipynb
--no-input removes every code cell and its In [ ] prompt, leaving text and outputs. Use --no-prompt to keep the code but drop the In [ ] / Out [ ] labels.
Hide only some cells with tags
- In JupyterLab, open the property inspector (gear icon) and add a tag to the cell, e.g.
remove_input(hide code, keep output) orremove_cell(hide everything). - Export with the tag remover turned on:
jupyter nbconvert --to pdf notebook.ipynb \
--TagRemovePreprocessor.enabled=True \
--TagRemovePreprocessor.remove_input_tags='{"remove_input"}' \
--TagRemovePreprocessor.remove_cell_tags='{"remove_cell"}'
The easy way: ipynbtopdfscanner
- Hide all code: switch off Show code in PDF settings.
- Hide one cell: tap or hover over it in the preview and choose Hide this cell. Undo is one tap away.
- Hide outputs, text or labels: use the Show outputs, Show text and In [ ] / Out [ ] switches.
- Cell tags
remove-cell,remove-input,remove-outputandhide-inputare respected automatically.
Skip the setup: convert your notebook to PDF in your browser, free and private.
Open the converterFrequently asked questions
Will hiding code remove the outputs too?
No. Hiding code (--no-input, remove_input or “Show code” off) keeps the outputs such as tables and charts.
Can I hide a cell without editing the notebook?
Yes. In ipynbtopdfscanner you hide cells in the preview; the .ipynb file itself is not changed.