as of now (nbconvert version 5.6.0) the easiest solution seems to be to provide the argument --no-input when using the CLI interface of nbconvert:
jupyter nbconvert yourNotebook.ipynb --no-input
it works like magic more info here
Answer from vincentVega on Stack Overflowas of now (nbconvert version 5.6.0) the easiest solution seems to be to provide the argument --no-input when using the CLI interface of nbconvert:
jupyter nbconvert yourNotebook.ipynb --no-input
it works like magic more info here
I wrote an article about different ways how to hide code in Jupyter Notebook. According to my findings, there are several ways in which this can be done.
1. Hide all code in nbconvert
When exporting notebook with nbconvert you need to add --no-input in the command:
jupyter nbconvert --to html --no-input your-notebook.ipynb
2. Hide selected cells
You can hide selected cells by adding a tag hide_code, like in the animation below:

The command that hide code only for selected cells:
jupyter nbconvert --to html --TagRemovePreprocessor.remove_cell_tags='{"hide_code"}' my-notebook.ipynb
3. Export to HTML with Mercury
The Mercury is an open-source for sharing notebooks with non-technical users. It can hide code. It can also generate widgets for the notebook that are connected with variables in the code. The notebook export process is controlled with YAML header, below is the example YAML that hides the code:
---
title: My notebook
description: My amazing notebook with hidden code
show-code: False
---
The example notebook with YAML header:

The HTML (website) generated for the notebook with Mercury:

python - export notebook to pdf without code - Stack Overflow
python - How export a Jupyter notebook to HTML from the command line? - Stack Overflow
Programmatically Export to HTML from Within Notebook With Custom Output Path
pandas - Generate pdf from jupyter notebook without code - Data Science Stack Exchange
Videos
I found this article interesting it explains how to remove the input columns :
you have to create a template file named "hidecode.tplx" in same directory as the notebook you want to convert and add those line in it :
((*- extends 'article.tplx' -*))
((* block input_group *))
((*- if cell.metadata.get('nbconvert', {}).get('show_code', False) -*))
((( super() )))
((*- endif -*))
((* endblock input_group *))
And after run this command it will use pdfLatex to convert the notebook in pdf via latex:
jupyter nbconvert --to pdf --template hidecode Example.ipynb
or if you want to edit you can convert it to a .tex document and use pdfLatex to put it in pdf :
jupyter nbconvert --to latex --template hidecode Example.ipynb
EDIT Sept 2018:
ipython nbconvert is deprecated. It will be replaced by jupyter nbconvert: So we replace the command ipython with jupyter
EDIT Feb 2021: (This is my best answer here, so let me take care of it)
Following @Mrule comment adding --no-input flag will make it work without the template...
jupyter nbconvert --to latex --no-input Example.ipynb
PS: If you are getting issue saying :
LaTeX error related to tcolorbox.sty not found
Please refer to this guide to update your tex installation and this question
I was seeking the same question in SO and finally turned out to a very straightforward way:
Assuming using Firefox(57) + Win7
- Run Jupyter notebook and download the notebook in the browser: File->Download as->HTML and you will get a html page with code and output.
- Open the exported HTML with browser and activate the browser console with key
F12 Run following command in the console:
document.querySelectorAll("div.input").forEach(function(a){a.remove()})The code removes all input div DOM. Then
right mouse buttonand chose "Save Page As" and Save the "Complete page" (not single page).You will get a page with an associated folder in windows. Use a trick by zip the html page and then extract to unbind the associated. The folder is useless.
Now it is a single html page without code. You can re-distribute it or print it as PDF.
If you are not using Firefox or Windows, please adjust the above 3-6 steps.
Also use --execute to get the output
jupyter nbconvert --execute --to html notebook.ipynb
This produces a notebook.html file.
The best practice is to keep the output out of the notebook for version control, see: Using IPython notebooks under version control
But then, if you don't pass --execute, the output won't be present in the HTML, see also: How to run an .ipynb Jupyter Notebook from terminal?
For an HTML fragment without header: How to export an IPython notebook to HTML for a blog post?
Tested in Jupyter 4.4.0.
Yes you can and it's quite easy and a built in feature
jupyter nbconvert --to html notebook.ipynb
That will generate a notebook.html file. Output can be customized. Also check out the slideshow functionality (View>Cell-Toolbar>Slideshow) which can also be used with nbconvert.
Also the notebook.ipynb Jupyter file can be uploaded to Github where the current version gets rendered. Depending on what you want that information might be useful too
Also check out line/cell magic. You can run bash commands directly in your jupyter cell like so:
%%bash
convert graphviz/MyPic.jpg -resize 70% graphviz/MyPic_sm.jpg
Try this:
jupyter nbconvert --to pdf --TemplateExporter.exclude_input=True my_notebook.ipynb
This also works for html output. You will find the documentation for this and other options here.
FYI, for complex notebooks, this may generate errors depending on your version of nbconvert, LaTeX and other components. In that case try to convert to html then print to pdf using a browser.
Make sure you are working with Qt Console (anaconda):
Install Jupiter extensions:
!pip install jupyter_contrib_nbextensions
!jupyter contrib nbextension install --user
Enable nbextension:
!jupyter nbextension enable codefolding/main
Install pyppeteer:
!python -m pip install -U notebook-as-pdf
!pyppeteer-install
MAKE SURE YOUR WORKING DIRECTORY IS WHERE YOUR Untitled.ipynb FILE IS SAVED
Save file to HTML format without codes:
!jupyter nbconvert Untitled.ipynb --no-input --no-prompt --to html
EXPORT TO PDF FORMAT:
!jupyter-nbconvert Untitled.ipynb --no-input --no-prompt --to pdfviahtml
PS. Exporting HTML and PDF format are mutually exclusive commands, you can use either.