IPYNB to Python Converter

Extract code cells from a saved Jupyter Notebook (.ipynb) into a downloadable .py script. Use it when you need notebook logic for Git diffs, code reuse, homework code submission, or moving analysis into a script.

student-score-analysis.ipynb

Script options

student-score-analysis.py

Sample preview is loaded. Upload a notebook to replace it.

Code cells
2
Markdown cells
1
Output cells
2

Monokai-inspired preview

Light code preview of the generated .py file. Full script downloads below.

.py
# Generated by IPYNB Tools IPYNB to Python Converter# Source: student-score-analysis.ipynb# Code cells extracted: 2# Notebook outputs are not preserved in .py scripts. Run the script to recreate results. # %% Cell 1import pandas as pdscores = pd.DataFrame({"score": [82, 91, 76]})scores.mean() # %% Cell 2scores["passed"] = scores["score"] >= 80scores 
Tool page

IPYNB to Python Converter

Extract code cells from a saved Jupyter Notebook (.ipynb) into a downloadable .py script. Use it when you need notebook logic for Git diffs, code reuse, homework code submission, or moving analysis into a script.

Local conversion

The notebook JSON is parsed in your browser for this code extraction workflow.

Code cells only

The .py output contains source code cells; rich outputs are not preserved.

No execution

The converter does not execute Python, shell commands, notebooks, or external dependencies.

When This Tool Fits

Use this converter when your notebook already contains the code you want to reuse as a Python script. It is best for Git diffs, refactoring notebook logic, code review, and class submissions that ask for source code instead of a report.

  • Git-friendly Python source
  • Notebook code reuse
  • Homework code submission
  • Script-first workflows

IPYNB to Python vs IPYNB to PDF

Python output is for code extraction. PDF output is for reports and reviewable documents with saved outputs. If your reader needs charts, tables, Markdown explanations, and visible results, use the IPYNB to PDF converter instead.

  • Use .py for source code
  • Use PDF for reports
  • Use Full Notebook PDF when code and outputs both matter

What Gets Lost in .py Output

A .py script does not carry notebook outputs. Rich display data, charts, tables, images, widgets, execution counts, and notebook metadata are not preserved as executable Python source.

  • Outputs are not preserved
  • Widgets are not preserved
  • Execution order still needs human review

Notebook cells become a Python script

The converter reads saved notebook JSON, keeps code cell source, and writes a .py script with optional # %% cell markers. Outputs, charts and tables are not copied into the script.

.ipynb cells

Markdown cell

Optional context comments

Code cell 1

import pandas as pd

Saved output

Excluded from .py

Code cell 2

scores["passed"] = scores["score"] >= 80

.py script

# %% Cell 1
import pandas as pd
scores = pd.DataFrame(...)
# %% Cell 2
scores["passed"] = scores["score"] >= 80

Example notebooks for Python extraction

These sample notebooks show the kinds of code-first notebooks that are safe to inspect as scripts.

Before You Download

Review the extracted script before using it. Notebook cells may depend on hidden state, previous execution order, magics, shell commands, or files that were available only in the original notebook environment.

  • Check imports
  • Review cell order
  • Replace notebook magics when needed
  • Run in a clean environment

What is preserved in .py output

A Python script is a source-code artifact. Review this matrix before choosing .py instead of PDF.

Code cells
Preserved
Source text is copied in notebook order.
Cell boundaries
Optional
Keep # %% cell markers for VS Code or notebook-style editors.
Markdown cells
Optional
Include them as # comments when context matters.
Notebook outputs
Not preserved
Rendered outputs are display data, not Python source.
Charts and tables
Not preserved
Use IPYNB to PDF when charts and tables must remain visible.
Magics or shell commands
Copied as text
Review % and ! commands before running the script outside Jupyter.

HowTo

Notebook to Python script workflow

Use this visible workflow to match the generated .py file with the original notebook structure before you reuse the code.

  1. 1

    Upload a saved .ipynb notebook

    Choose a Jupyter Notebook file from your device.

  2. 2

    Review detected cells

    Check the detected code cells, markdown cells, and output cells before downloading.

  3. 3

    Choose script options

    Keep # %% cell markers and optionally include markdown as comments.

  4. 4

    Download the .py file

    Download the extracted Python script or copy the code.

Why IPYNB Tools for IPYNB to PY

IPYNB Tools keeps this page focused on one job: extracting notebook source into a reviewable Python script without pretending that outputs become source code.

Clear boundary
The page states that outputs, widgets, images, and execution counts are excluded.
Script-first defaults
Cell markers are enabled so editors such as VS Code can navigate extracted cells.
Same notebook suite
When you need a report instead of source code, the PDF converter is one click away.

When to choose IPYNB to PY

Use the .py output when the next step is editing, reviewing, or running source code outside the notebook UI.

Best for

  • Best for Git diffs when reviewers need Python source instead of notebook JSON.
  • Best for moving working analysis code into a script-first project structure.
  • Best for classroom or code review submissions that ask for source code.

Not for

  • Not for final reports with charts, tables, and saved outputs; use IPYNB to PDF instead.
  • Not for reproducing a notebook environment automatically; dependencies and execution order still need review.
  • Not for preserving widgets, images, rich display data, or execution counts.

Specs and limitations

IPYNB Tools · Code extraction for notebooks

IPYNB Tools editorial · Updated May 16, 2026

Local JSON parsingCode cells onlyNo execution
Input
.ipynb Jupyter Notebook
Output
.py Python script
Best for
Git diffs, source review, reuse
Input
Standard .ipynb Jupyter Notebook JSON files.
Output
A .py Python script generated from code cells.
Markdown
Optional markdown comments can be included for context.
Execution
Notebook code is not executed.
Outputs
Notebook outputs are not preserved in the script.
Best fit
Code extraction, Git review, reuse, and script migration.

FAQ

What does the IPYNB to Python converter extract?

It extracts notebook code cells from a saved .ipynb file and combines them into a downloadable .py script. Markdown cells can optionally be included as Python comments.

Are notebook outputs, charts, and tables preserved?

No. A Python script stores code, not rendered notebook outputs. Charts, tables, rich display results, execution counts, and widgets are not preserved in the .py file.

Does this run my notebook code?

No. The converter reads the notebook JSON and extracts source text only. It does not execute Python, shell commands, notebooks, local files, or external dependencies.

When should I use PDF instead of Python?

Use IPYNB to PDF when you need a report, homework document, or shareable artifact with saved outputs. Use IPYNB to Python when you need source code for Git diffs, reuse, or script-based workflows.

Is IPYNB to PY the same as IPYNB to Python?

Yes. IPYNB to PY and IPYNB to Python usually describe the same task: extracting source code from a .ipynb notebook into a .py Python script.

Does it keep # %% cell markers for VS Code?

Yes, cell markers are enabled by default. The generated script can include # %% cell markers so VS Code and notebook-style script editors can navigate extracted cells.

What happens to notebook magics or shell commands?

Magics or shell commands are copied as source text when they appear inside code cells. Review lines beginning with % or ! before running the .py script outside Jupyter.

How is this different from jupyter nbconvert --to script?

jupyter nbconvert --to script is a local command-line workflow. This page gives a browser-based preview and download flow for quick code extraction, but you should still review dependencies and execution order.

Should I use this if I need charts and tables?

Use IPYNB to PDF instead when charts and tables must stay visible. The .py output is for source code, not rendered notebook results.