A completed Jupyter Notebook can be exported as HTML when reviewers need the rendered narrative, code, and saved output without access to a running notebook server. nbconvert reads the .ipynb file and writes a browser-openable page that can be attached, archived, or published as a static artifact.
The HTML exporter uses the same jupyter nbconvert command shape as other notebook exports. The lab template is the current default for HTML output, and --embed-images keeps image outputs inside the generated file when the artifact needs to travel as one page.
Exporting does not run cells by default. Save the notebook after producing the outputs that should appear in the HTML file, or execute it separately before export when the rendered page must include fresh results.
Steps to convert a Jupyter Notebook to HTML with nbconvert:
- Save the notebook with the output cells that should appear in the HTML file.
nbconvert exports the saved notebook state. If the notebook must be rerun first, execute it before converting.
Related: How to execute a Jupyter Notebook from the command line - Convert the notebook to HTML.
$ jupyter nbconvert --to html --embed-images analysis-demo.ipynb [NbConvertApp] Converting notebook analysis-demo.ipynb to html [NbConvertApp] Writing 278012 bytes to analysis-demo.html
Replace analysis-demo.ipynb with the notebook file to export. The output keeps the same base name and uses .html.
- Check that the HTML file was written.
$ ls -lh analysis-demo.html -rw-r--r-- 1 user user 272K Jul 6 12:27 analysis-demo.html
- Open analysis-demo.html in a browser and confirm that the notebook title, markdown cells, code cells, and saved output appear without a Jupyter login prompt.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.