Cell markers become cells
A line that opens with # %% — with or without a space, with or without a title — starts a new code cell, exactly like the percent format nbconvert and Jupytext write.
PY to IPYNB
Drop in a .py file and download a valid .ipynb notebook: # %% cell markers become cells, [markdown] blocks come back as prose, and scripts without markers are split at their top-level definitions. Nothing is uploaded anywhere.
Converted in your browser — the script is never uploaded. You can also drop it anywhere on this page.
That file could not be opened
script.py
Notebook preview (first 200 lines)
The notebook is assembled in this tab from the script you chose. Nothing is uploaded, and the download is yours alone — the same file every time for the same script.
Need it the other way? Convert a notebook to PY0 bytes uploaded
Parsing and notebook assembly happen on your device.
nbformat 4.5 output
The current notebook format every Jupyter tool reads.
# %% cell markers
Percent markers, Spyder separators and In[] prompts all open a cell.
100% of the code kept
Code is copied unchanged — indentation, magics and all.
What the notebook keeps
The converter reads the script as text and rebuilds its structure, so the result is a real nbformat file you can open, run and commit — not an empty wrapper around one blob of code.
A line that opens with # %% — with or without a space, with or without a title — starts a new code cell, exactly like the percent format nbconvert and Jupytext write.
Inside a # %% [markdown] block the comment prefixes are removed, so headings, lists and notes that a script export turned into comments come back as markdown cells.
No markers? The script is split at its top-level def, class and decorator boundaries, so a module becomes a series of cells instead of one wall of code.
Everything else passes through as written, including magics like %matplotlib inline and shell lines like !pip install, which are valid notebook content.
Cell ids are derived from the cell text rather than random, so converting the same script twice produces the same file — and a diff shows the code, not the noise.
The file is nbformat 4.5 with a Python 3 kernelspec and no stored outputs: open it in Jupyter, JupyterLab, Colab, Kaggle or VS Code and run all cells.
Compatibility
Anything that is valid Python converts; these are the separators and edge cases the reader knows about.
Cell separators recognised
Split without markers
Notebook output
Known limits
How it works
Drop in a .py file and download a valid .ipynb notebook: # %% cell markers become cells, [markdown] blocks come back as prose, and scripts without markers are split at their top-level definitions. Nothing is uploaded anywhere.
Drop the script in
Choose a .py file or drag it onto the page; it is read on your device and the notebook is assembled immediately.
Check the cells
The preview shows the notebook JSON: one cell per separator, markdown restored, everything else copied unchanged.
Download the .ipynb file
Save script.ipynb next to your project and open it in Jupyter, JupyterLab, Colab or VS Code — then run the cells.
Five ways to turn a Python script into a notebook, from the browser converter above to the tooling built into Jupytext, VS Code and Jupyter itself — pick the one that fits where you already are.
The command-line standard: jupytext --to notebook script.py writes script.ipynb beside it, and --set-formats py:percent,ipynb pairs the two files so every save updates both. It needs Python and an install — the route to choose when the script already lives in a project you control.
VS Code reads a percent script as cells: the # %% lines become cell boundaries you can run in the interactive window, and the Jupyter extension converts the open file to a notebook from the command palette. Convenient when the script is already open — little use when it is a download sitting in your file manager.
Jupyter Notebook and JupyterLab open a notebook with File → Open or the upload button; Colab uses File → Upload notebook. That is the second half of every route on this page: the converter produces the file, Jupyter opens it.
Colab can open a .py file, but only as a text editor view — no cells, no markdown. Convert the script to .ipynb here first, then upload it in Colab to get the real notebook experience.
A small Python package that turns scripts documented with markdown into notebooks. Handy inside a build pipeline; for a one-off conversion there is nothing to install behind the converter at the top of this page.
In a hurry? Use the converter at the top.
The browser converter above reads the same scripts as every route on this page and produces the same nbformat 4.5 notebook — with nothing installed and nothing uploaded.
FAQ
Short answers about converting a Python script to a Jupyter notebook — how cells are found, what happens to comments, and whether the notebook runs as-is.
Use the converter at the top of this page: choose or drop in a .py file and the browser turns it into a notebook — cell markers split it into cells, commented prose becomes markdown, and the code is copied unchanged. Then download the .ipynb file and open it in Jupyter, JupyterLab, Colab or VS Code. No upload, no install and no terminal involved.
Run jupytext --to notebook script.py, which writes script.ipynb next to it and can pair the two files so every save updates both. Jupytext is a Python package, so it needs an install — this page does the same job in the browser, with nothing to set up.
If the script contains cell separators — # %%, #%%, # <codecell> or # In[3]: — each one opens a new cell, and a [markdown] separator makes it a markdown cell. With no separators at all, the script is split at its top-level def, class and decorator boundaries, with imports and top-level statements staying in the first cell.
No. Markers give the most faithful cells, but a plain module converts fine without them — the reader splits it at top-level definitions. Add markers only where you want the cell boundaries to fall somewhere else.
They stay exactly where they are. A normal comment is part of its code cell and is copied unchanged. Comments turn into markdown in one case only: inside a # %% [markdown] block, where the prefix is stripped and the text becomes proper markdown.
The code is copied unchanged in script order, so yes — run all cells and it behaves like the script did. Two honest caveats: there are no stored outputs to begin with, so you have to run the cells, and Jupyter magics like %matplotlib inline keep working only inside a real IPython kernel.
Yes. In Colab use File → Upload notebook and pick the .ipynb file. Colab accepts .py files too, but opens them as plain text — the converted notebook is the version that gets cells, markdown and a kernel.
Jupytext is the right tool inside a project: it can pair a script and a notebook so every save writes both files. This converter runs in the browser instead — nothing is installed, nothing is uploaded, and it works on any machine, which is useful when a script lands in your inbox and you just want a notebook out of it.
No. The file is read with the browser File API and turned into a notebook inside the tab. You can disconnect from the network after the page loads and the conversion still works — which is also the practical proof that nothing is uploaded.
The code comes back intact, but the round trip is not a restore: outputs and execution counts are gone (the script never contained them), and markdown returns as markdown only where it was written as a commented [markdown] block. Use it to move working code into a notebook, not to recover a notebook whose .ipynb file is lost.
Drop it in, download the .ipynb and open it in Jupyter — the code is already there; you only add the outputs you want.
Convert a script to IPYNB