Convert PY to IPYNB in Your Browser
Turn a Python script (.py) into a Jupyter Notebook, splitting it into cells on the # %% markers your editor already writes. No Python, no jupytext install, and no upload: the script never leaves your device.
Drag and drop, paste, or click to select Tap to select a .py file
Files are processed on your device only.
How it works
- Drop, paste, or select your .py file. It is read on your device only.
- Check the note that says how the script was split into cells.
- Click Download .ipynb and open the notebook in Jupyter or VS Code.
How the script is split, and what is never guessed
If the file contains # %% lines, those are the cell boundaries, used exactly as written. Anything above the first marker becomes a leading code cell, so a shebang, a docstring, and a block of imports stay together at the top. A marker written as # %% [markdown] produces a markdown cell, with one leading comment hash stripped from each line so the prose reads as prose.
If the file has no markers, you get one code cell. That is a deliberate choice: heuristics based on blank lines or on where functions start yield notebooks that look plausible and break in the middle of a block, and a wrong split is more work to undo than a single cell is to divide. The tool states which of the two happened rather than leaving you to inspect the result.
Round-tripping between script and notebook
Scripts are what version control, code review, and linters handle well; notebooks are what exploration and teaching handle well. The percent format lets one file serve both, and this page is the direction that turns the script back into the notebook. Run the pair in reverse with IPYNB to PY and the markers survive the trip, so a file can go back and forth without drifting.
The generated notebook is nbformat 4 with a Python 3 kernelspec, which is what Jupyter, JupyterLab, Colab, and VS Code all expect. If you only want a readable copy of the code rather than a runnable notebook, the PY to PDF converter prints it with syntax highlighting instead. See how browser-side rendering works for the shared pipeline.
Frequently asked questions
- What happens to a script that has no cell markers?
- It becomes a single code cell, and the tool says so. Splitting on blank lines or on def statements produces notebooks that look reasonable and put boundaries in the wrong places, which is worse than one honest cell you can split in Jupyter with a keystroke. Add # %% on its own line wherever you want a break, then convert again.
- Which cell markers are recognised?
- The percent format: a line reading # %% starts a code cell and # %% [markdown] starts a markdown cell, with the leading comment hash stripped from each line of prose. This is the same convention VS Code, Spyder, PyCharm, and jupytext use, and the same one the IPYNB to PY converter here writes.
- Are the cells executed, and will there be outputs?
- No and no. The notebook is written with every cell unexecuted, an execution count of null, and an empty outputs list, exactly as a fresh notebook looks. Nothing here runs Python, so open the file in Jupyter and run the cells to produce results.
- Is my script uploaded anywhere?
- No. The file is read and the notebook JSON is assembled in your browser on your own device. There is no upload endpoint, no account, and the converter keeps working with the network disconnected, which matters for code you would rather not paste into an online box.