How to Convert .ipynb to PDF
Published on
Updated on

A .ipynb file is a Jupyter Notebook: JSON that bundles your code, outputs, charts, and markdown. A PDF flattens all of that into one portable document anyone can open, print, or attach — which is why notebooks usually get exported to PDF for reports, assignments, and reviews.
Quick answer
The fastest way to convert a notebook to PDF is nbconvert, which ships with Jupyter:
jupyter nbconvert --to pdf notebook.ipynbThat route renders through LaTeX. If you do not have a TeX distribution installed (the common xelatex not found error), use the Chromium-based exporter instead — no LaTeX required:
pip install "nbconvert[webpdf]"
jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynbIf you would rather not install anything, open the notebook in VSCode, Jupyter, or Google Colab and print to PDF. Pick the method that matches what you already have:
| Method | Install needed | Best for |
|---|---|---|
nbconvert --to pdf | Jupyter + LaTeX | Clean, publication-style PDFs |
nbconvert --to webpdf | Jupyter + Chromium | Same, but no LaTeX setup |
| VSCode export | VSCode + Jupyter ext. | People already coding in VSCode |
| Browser / Jupyter print | Nothing extra | One-off, fastest no-setup route |
| Google Colab print | Nothing (cloud) | Notebooks already in Colab |
| Online converter | Nothing | No local Python at all |
Method 1: nbconvert (the canonical way)
nbconvert is the official Jupyter export tool. The PDF exporter converts your notebook to LaTeX, then compiles it, so you need both Jupyter and a TeX distribution (TeX Live, MiKTeX, or MacTeX) plus Pandoc.
# one-time setup if you do not have them
pip install nbconvert
# install a LaTeX distribution + pandoc via your OS package manager
# convert
jupyter nbconvert --to pdf notebook.ipynbThis produces notebook.pdf in the same folder. It gives the most polished, print-ready result, but the LaTeX dependency is the part that trips most people up (see Troubleshooting).
No LaTeX? Use webpdf
The webpdf exporter renders the notebook with a headless Chromium browser instead of LaTeX, so you skip the entire TeX install:
pip install "nbconvert[webpdf]"
jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynbThe first run downloads a small Chromium build. After that, conversions are fast and the layout matches what you see in the browser.
HTML as a fallback
When both routes fail, export to HTML and print that page to PDF from your browser. It always works:
jupyter nbconvert --to html notebook.ipynbMethod 2: Export to PDF in VSCode
If you already edit notebooks in Visual Studio Code with the Jupyter extension:
- Open the
.ipynbfile in VSCode. - Click the
...(More Actions) menu at the top of the notebook. - Choose Export and select PDF.
VSCode uses nbconvert under the hood, so the same LaTeX dependency applies. If the PDF export errors out, export to HTML from the same menu and print that to PDF.
Method 3: Print to PDF (no install)
Every notebook environment can reach "Print", and every OS can print to PDF. This is the quickest path when you just need one file.
- Jupyter Notebook / JupyterLab:
File > Save and Export Notebook As… > HTML, open the HTML, thenCtrl/Cmd + P > Save as PDF. Classic Notebook also hasFile > Download as > PDF via LaTeX. - Any browser: with the notebook or its HTML open, press
Ctrl/Cmd + Pand choose Save as PDF as the destination.
The tradeoff: long cells can break awkwardly across pages, so review the output.
Method 4: Google Colab
If your notebook lives in Google Colab, you do not need anything installed locally:
- Open the notebook in Colab.
- Go to File > Print.
- In the print dialog, set the destination to Save as PDF.
Colab renders the page through the browser, so the result mirrors the on-screen layout.
Method 5: Online converters
When you have no local Python at all, an online converter handles the conversion in the browser. Upload the .ipynb, pick PDF, and download the result.
RunCell (opens in a new tab) offers a free online ipynb-to-pdf converter — upload your notebook, click convert, download the PDF.
Other general-purpose options include Vertopal and OnlineConvertFree. Avoid uploading notebooks that contain credentials, private data, or proprietary code to third-party sites.
Troubleshooting
nbconvert failed: xelatex not found / PDF creating failed
The PDF exporter needs LaTeX. Either install a TeX distribution (TeX Live, MiKTeX, MacTeX) and Pandoc, or switch to the no-LaTeX route:
jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynbnbconvert: command not found
nbconvert is not installed or not on your PATH. Install it and call it through Python to be safe:
pip install nbconvert
python -m jupyter nbconvert --to pdf notebook.ipynbPlots or wide tables get cut off
LaTeX page width is fixed. Reduce figure size in the notebook before export, or use --to webpdf / HTML print, which wrap content to the page more forgivingly.
Output is missing cells
Make sure the notebook is saved and all cells have run. nbconvert exports the saved state, not the live kernel, so re-run and save before converting.
FAQ
What is the command to convert ipynb to PDF?
Run jupyter nbconvert --to pdf notebook.ipynb. If you do not have LaTeX installed, use jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynb instead.
How do I convert ipynb to PDF without LaTeX?
Use the webpdf exporter (pip install "nbconvert[webpdf]" then --to webpdf), or export to HTML and print to PDF from your browser. Both avoid a TeX installation.
How do I convert ipynb to PDF in VSCode?
Open the notebook, click the ... menu at the top, choose Export, and select PDF. VSCode uses nbconvert, so install LaTeX or export to HTML if the PDF step fails.
How do I convert a Colab notebook to PDF?
In Google Colab, open the notebook and use File > Print, then set the destination to Save as PDF.
How do I convert ipynb to HTML instead?
See our guide on converting .ipynb to HTML.
Related Guides
- How to Convert .ipynb to HTML
- How to Start JupyterLab
- What is
__pycache__in Python - How to Run Python Scripts
