IPYNB Hub 中文 Convert free

Free · runs 100% in your browser

IPYNB to PY: extract a clean Python script locally

Convert Jupyter and Google Colab .ipynb notebooks into clean .py Python scripts in your browser. Zero upload, optional # %% cell markers and magic handling.

  • No upload
  • Handles % / ! magics
  • VS Code # %% ready

Drop your .ipynb file here

or

Converted on this device — never uploaded

Works with .ipynb files from

  • Google Colab
  • Jupyter
  • JupyterLab
  • VS Code
  • Kaggle
  • Deepnote

3 steps

How to convert an ipynb file to py in 3 steps

Clean Python extraction without installing nbconvert or uploading proprietary source code.

  1. 1

    Load your .ipynb file

    Drop your .ipynb file into the extractor or click the sample notebook to test the output format.

  2. 2

    Pick script options

    Toggle # %% cell markers, Markdown comments, and % / ! IPython magic commenting to match your workflow.

  3. 3

    Copy or download .py

    Review the generated Python script live, then copy it to your clipboard or download the .py file.

Why convert ipynb to py in the browser?

Notebooks are built for interactive exploration, but production jobs, Git pull requests, code reviews, and CI pipelines expect plain .py files. Moving code out of a .ipynb JSON wrapper by hand means copying dozens of cells one by one while avoiding saved HTML tables and base64 image strings. Our ipynb to py converter reads the notebook JSON locally in your browser and extracts every code cell into a clean UTF-8 Python script in milliseconds, without uploading proprietary code to an external server.

Unlike jupyter nbconvert --to script, you do not need Python, Jupyter, Pandoc, or Conda installed on the machine you are using. Every option updates the preview live so you can verify the extracted Python script before copying it or saving the .py file to disk.

Cell markers, Markdown comments, and IPython magics

  • Include # %% cell markers: Adds VS Code, Spyder, and PyCharm scientific cell dividers (# %% and # %% [markdown]) between blocks. That lets you keep running cells interactively inside an IDE after converting, or collapse sections cleanly. Turn this off when you want a minimal flat script for CLI execution or packaging.
  • Markdown as comments: Preserves Markdown narrative cells as # comment blocks above the code they explain so section titles and doc notes stay intact. Uncheck this option to strip all prose and keep executable code cells only.
  • Comment out % / ! magics: Notebooks exported from Google Colab and Jupyter often contain IPython directives such as %matplotlib inline, %load_ext autoreload, %timeit, or !pip install. Those lines raise SyntaxError in standard python script.py runs. Keeping this option enabled prefixes them with # [notebook magic] so the exported .py file stays syntactically valid out of the box.

What happens to cell outputs and charts?

Plain .py scripts only hold source code and comments, so DataFrames, stdout logs, and PNG/SVG plots are intentionally excluded during extraction. That keeps your .py file lightweight, diff-friendly in Git, and ready to refactor into modules or scheduled batch jobs. Empty cells are automatically skipped to avoid cluttering the output with blank dividers.

Common issues when converting ipynb to py

The exported script fails with NameError or SyntaxError on a magic command. Make sure Comment out % / ! magics is checked before downloading, and check whether the notebook relied on IPython-only helpers such as display() or get_ipython(), which require either replacing with print() or importing from IPython.display.

My notebook uses older nbformat 3. Both nbformat 4 (cells) and legacy nbformat 3 (worksheets) are supported automatically, so older classroom or archive notebooks extract cleanly.

The notebook contains non-Python code. If a notebook runs an R, Julia, or Bash kernel, the extractor still pulls every code cell cleanly without corrupting indentation, though you should rename the downloaded file extension to match that language.

I need to share results instead of raw code. Python .py files drop all tables, formulas, and charts. If a colleague or instructor needs to see your outputs, use our IPYNB to PDF converter, inspect the notebook in the IPYNB viewer, or export a web page with IPYNB to HTML.

Frequently asked questions

Spotted an edge case? Email contact@ipynbhub.com.

Is my notebook uploaded when converting ipynb to py?

No. The .ipynb JSON is parsed locally inside your browser tab via FileReader, and the .py file is generated in memory with a Blob download. Nothing is uploaded.

What are # %% cell markers for?

Adding # %% markers lets editors like VS Code, PyCharm Professional, and Spyder recognize each original notebook cell as a runnable code block. You can turn them off for a plain script.

How does the converter handle %matplotlib or !pip commands?

Lines starting with % (IPython line magics like %matplotlib inline) or ! (shell commands like !pip install) cause SyntaxError in standard Python. Enabling Comment out % / ! magics prefixes them as safe comments.

Can I exclude Markdown cells and keep code only?

Yes. Leave Markdown as comments checked to keep explanations as # comments, or uncheck it to extract code cells only.

Does it work with Google Colab and legacy notebooks?

Yes. Both modern nbformat 4 notebooks (Colab, JupyterLab, VS Code) and legacy nbformat 3 notebooks are supported.

More tools

More local notebook tools

Switch between viewing, PDF printing, HTML export, and Python extraction — zero upload across every tool.

Turn your notebook into clean Python.

Free, private, no sign-up. Your .ipynb file never leaves your computer.

Extract a .py script