ipynb to pdf
  • IPYNB to PDF
  • Jupyter
  • Google Colab
  • VS Code

How to Convert IPYNB to PDF in Jupyter, Colab and VS Code

Four working routes from .ipynb to PDF: nbconvert, Colab's print dialog, VS Code and a browser converter that shows page breaks before you export.

The IPYNB to PDF team6 min readUpdated

A notebook is the right shape for work in progress and the wrong shape for almost everyone you send it to. The reviewer does not have your kernel, the client does not want a Jupyter install, and the journal submission portal accepts a PDF and nothing else. So the last step of the project becomes a format question: how do you get the .ipynb file into a document that opens anywhere?

There are four routes, and they fail in different ways. This guide walks through each one, what it preserves, and when to pick it.

What “IPYNB to PDF” actually means

An .ipynb file is JSON: an ordered list of code, markdown and raw cells, with the stored output of every code cell. Turning it into a PDF means laying those cells out on fixed pages, which is a different problem from reading them in a scrolling tab. A 14-column DataFrame that scrolls sideways on screen has to become a table that fits a page or is scaled to fit it. A matplotlib figure that resizes with the window has to be measured once and drawn at a fixed width.

That is why a PDF export can look perfect in one tool and like a screenshot in another: the tools disagree about how much layout work to do.

Route 1: convert in the browser

The shortest route needs no install and no upload. Open the IPYNB to PDF converter, drop the notebook in, and the page parses it locally, lays it out at the width of the printed page, and previews the pagination.

  1. Choose or drag the .ipynb file onto the converter.
  2. Set A4 or US Letter, portrait or landscape, light or dark.
  3. Decide whether code, outputs, In[]/Out[] prompts and line numbers belong on the page.
  4. Check where the pages break, then download the PDF or print to PDF.

Because the file is read with the browser’s File API and never sent anywhere, this route also works offline once the page has loaded. It handles nbformat 4 and the older nbformat 3 worksheets, attachments stored as base64, ANSI colour codes in text output, and LaTeX in markdown cells.

The trade-off is that everything runs in a tab: a notebook with hundreds of high-resolution figures can exhaust the memory a browser gives it.

Route 2: nbconvert on the command line

nbconvert is the standard Jupyter exporter and the route most tutorials assume:

pip install nbconvert
jupyter nbconvert --to pdf notebook.ipynb

This is not a self-contained command. --to pdf renders the notebook to LaTeX and compiles it with xelatex, so it needs Pandoc and a TeX distribution (TeX Live, MacTeX or MiKTeX) on your PATH. When they are missing you get xelatex not found on PATH and no PDF. The nbconvert troubleshooting guide covers that error and its siblings in detail.

Useful flags once it works:

# A different template, no code, no prompts
jupyter nbconvert --to pdf --template classic --no-input --no-prompt notebook.ipynb

# Run the notebook first so outputs are current
jupyter nbconvert --to pdf --execute notebook.ipynb

nbconvert gives you a build you can script, which matters when a report is generated on every commit. It also gives you the most control over the final typography — if you are willing to write a LaTeX template.

Route 3: Colab

Colab has no PDF export button. The two honest answers are:

  • Print to PDF. File → Print, then choose Save as PDF as the destination. Fast, and the text is selectable, but the browser decides where pages break. Long outputs and wide tables often land badly.
  • Download and convert. File → Download → .ipynb saves the notebook, then convert that copy with the browser converter or nbconvert. This is the route to take when the result has to look deliberate.

Colab adds its own metadata (metadata.colab) and often stores large outputs inline, so a downloaded Colab notebook can be several megabytes before you have added a single figure. That is normal and does not need cleaning up first.

Route 4: VS Code

The Jupyter extension in VS Code exports HTML, Python scripts and .ipynb files — not PDFs. Three workarounds:

  1. Export to HTML, then print. Run Jupyter: Export from the command palette, open the HTML file in a browser and print to PDF. No installs beyond VS Code.
  2. Use the terminal. jupyter nbconvert --to pdf from the integrated terminal, if you already have Pandoc and TeX installed. See Route 2.
  3. Open the file in a browser converter. Drop the same .ipynb file into the converter and download. No LaTeX, and the page breaks are visible before you commit.

The HTML export is the fastest option and the least controlled; the browser route is the one that produces a document rather than a printout.

Route 5: print the notebook from the browser

If you only need something readable, printing the notebook’s own preview is legitimate. In Jupyter Notebook or JupyterLab, File → Print Preview opens a clean rendering; in Colab, File → Print does the same. The browser’s Save as PDF destination then writes the file.

The advantage is real: the text is vector, selectable and searchable, and the file stays small. The disadvantage is that page breaks are chosen by the print engine, which knows nothing about cells. A figure can be split down the middle, and a heading can be left alone at the bottom of a page.

Which route should you use?

Route Installs needed Page-break control Text selectable Best for
Browser converter None High — preview before export No (rasterised pages) Sharing, submitting, printing
nbconvert --to pdf Pandoc + TeX High, via template Yes Scripted, repeatable builds
Colab print None Low Yes A quick copy for yourself
VS Code HTML + print None Low Yes A one-off export with no installs
Print preview None Low Yes Long reports read on screen

The pattern: if the PDF is going to someone else, use a route that measures the cells. If it is going to you, print is enough.

What to check before you send the PDF

  • Figures are whole. No plot cut across a page boundary.
  • Tables keep their headers. A table split over three pages without a repeated header is unreadable.
  • Code is not clipped. Long lines should wrap or the block should split at a line boundary, never mid-character.
  • Markdown became typography. Headings, lists and links should read as a document, not as raw asterisks.
  • The first page says what this is. Notebook name, kernel, cell count and date are worth a title block.
  • Math typeset. Inline and display LaTeX should match what the notebook previews.

Frequently asked, briefly

Do I need to run the notebook before converting? No. Conversion uses the outputs already stored in the file. If you need fresh results, execute first — in JupyterLab with Run All, in Colab with Runtime → Run all, or with nbconvert --execute.

Why are my plots blurry? Some exporters rastersise the whole page. A converter that measures each block and draws it separately keeps figures at full resolution. If text is blurry too, you are looking at a screenshot, not an export.

Can I convert a notebook without installing Python? Yes. Both the browser converter and Colab’s print dialog need nothing installed. nbconvert is the route that needs Python and, for PDF, TeX.

Does converting execute my code? Not in the browser converter — it only reads stored outputs. nbconvert --execute is the exception, and it runs the notebook in a kernel, so never point it at a file you do not trust.

Ready to try the shortest route? Drop a notebook into the converter and compare the result with whatever you have been using.