# Sharing a Notebook as a Web Page

Run Restart and Run All, then turn the notebook into a web page anyone can open with jupyter nbconvert --to html, add --no-input to hide the code from readers who don't want it, or use VS Code's Export, which runs nbconvert too; PDF needs extra programs, and a notebook's saved outputs make its Git history noisy, so readers get the HTML.

Journeyman · Python · Updated November 19, 2026

By Gregor Dzierzon

## After this lesson you can

- Run Restart and Run All, then export a notebook to HTML with jupyter nbconvert --to html, and hide the code with --no-input
- Choose how to share a notebook, as HTML, from VS Code's Export or as a PDF, and explain why its outputs make Git history noisy

## Key takeaways

- Run Restart and Run All, and save, before you share, because a copy of a notebook shows what the saved file holds.
- jupyter nbconvert --to html story.ipynb writes story.html, a web page that opens in any browser, with no Python needed.
- Add --no-input to leave the code out, so a reader sees the words, the tables and the results.
- VS Code's Export makes the same page with nbconvert. PDF needs extra programs installed, so this course shares HTML.
- A notebook keeps its outputs inside the file, so a rerun changes many lines in Git. Commit the notebook for its history, and send readers the HTML.

Your story notebook is finished, and Denise, who runs Pine Valley Community Center, needs to read it. She doesn't have VS Code or Python, and she shouldn't need them. Sending an `.ipynb` file doesn't work: double-clicked, it opens as a wall of JSON, or not at all. Screenshots lose the tables' text and every link. What opens anywhere, on any computer or phone, is a web page. This lesson turns a notebook into one, the way you'll share every analysis you hand to someone who doesn't code.

## First, Restart and Run All

A web page made from a notebook shows what the saved file holds: every output as it was last saved, stale ones included. If a cell ran twice, or a cell you deleted made a name another cell uses, the page shows numbers nobody can reproduce, as *The Kernel: Why Run Order Matters* showed.

So before sharing, click **Restart**, then **Run All**, in the notebook's toolbar. Check that the execution counts read 1, 2, 3 and on down the page, and that no cell shows an error. Then save with **Ctrl+S** (**Cmd+S** on a Mac). The file now holds a clean run from the top, and that's what you'll share.

## jupyter nbconvert --to html

**nbconvert** (read "n b convert") is the Jupyter tool that converts a notebook to other formats. It's a Python package, so it goes in the project's virtual environment: this module's exercises list it in `requirements.txt`, and in a project of your own you install it with `pip install nbconvert`. With the virtual environment on, in the notebook's folder:

```bash
jupyter nbconvert --to html story.ipynb
```

```text
[NbConvertApp] Converting notebook story.ipynb to html
[NbConvertApp] Writing 288376 bytes to story.html
```

It writes `story.html` beside the notebook, in the same folder; the size you see will differ a little. Double-click it and it opens in your browser: the title, the Markdown, each code cell with its result, and the tables drawn as grids. **HTML** is the language web pages are written in, so any browser shows the file, and you can email it or put it in a shared folder. The notebook itself doesn't change.

## --no-input: the story without the code

Denise wants the story, not the Python. Add `--no-input`, and the page leaves out every code cell's code and keeps its result:

```bash
jupyter nbconvert --to html --no-input story.ipynb
```

```text
[NbConvertApp] Converting notebook story.ipynb to html
[NbConvertApp] Writing 284247 bytes to story.html
```

Now `story.html` reads like a report: headings, sentences, lists and tables, with each result right where its code cell was. It writes over the `story.html` from before, so if you want both, make the one with code first and rename it. Send the version with code to someone who wants to check your work, such as a teammate or a grader.

## VS Code's Export, and PDF

You can do the same without the terminal. At the top of the notebook in VS Code, click the **...** (More Actions) button in the notebook's toolbar, then **Export**, and choose **HTML**. VS Code asks where to save the file. It runs nbconvert from the notebook's kernel, so it needs nbconvert installed in that `.venv` too.

![VS Code's notebook toolbar with the More Actions menu open and Export highlighted, and the list of formats below it with HTML, PDF and Python Script](https://www.ask-codey.com/lessons/TODO)

**PDF** is on the same list, but nbconvert's PDF needs extra programs installed outside Python: Pandoc and a LaTeX system, which together take a large download. Without them, it stops with `Pandoc wasn't found.` This course shares HTML. If someone needs a PDF, open the HTML page in your browser and use its **Print** command with **Save as PDF**.

## Notebooks, outputs and Git

A notebook saves its outputs inside the `.ipynb` file: every table as text and as HTML, every chart as a long block of encoded text. Rerun it after the data changes and those outputs change, so `git diff` shows hundreds of changed lines for what was a one-number update, and the history gets hard to read.

So commit the notebook for its history, with its outputs when someone needs to see them, as this course's exercises do (their tests read the outputs). Send readers the HTML, not the notebook: it's one file they can open, it can't be run out of order, and it doesn't fill your repo's history with output. Many projects list the HTML in `.gitignore` for that reason.

## Check yourself

2 questions to try on the lesson page.

## So what

A report is finished when it reaches its reader: run the notebook from a fresh start, save it, and send them a web page they can open anywhere, with or without the code.

## Key terms

- [nbconvert](https://www.ask-codey.com/glossary/nbconvert)
- [Restart and Run All](https://www.ask-codey.com/glossary/restart-and-run-all)
- [HTML](https://www.ask-codey.com/glossary/html-html)
- [git diff](https://www.ask-codey.com/glossary/git-diff)

## Related

- [A Notebook That Tells a Story](https://www.ask-codey.com/lessons/data-notebook-that-tells-a-story)
- [The Kernel: Why Run Order Matters](https://www.ask-codey.com/lessons/data-notebooks-kernel-and-run-order)

Source: https://www.ask-codey.com/lessons/data-exporting-notebooks
