Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Document Python script conversion support (#5795)

Trevor Manz26fa56ecb7f6
diff --git a/docs/getting_started/quickstart.md b/docs/getting_started/quickstart.md
index 909366015f..33ad59900e 100644
--- a/docs/getting_started/quickstart.md
+++ b/docs/getting_started/quickstart.md
@@ -54,12 +54,16 @@ python your_notebook.py
You can also [pass CLI args](../guides/scripts.md) to your notebook.
-## Convert from Jupyter to marimo
+## Convert Jupyter notebooks and Python scripts to marimo
-Automatically convert Jupyter notebooks to marimo notebooks with `marimo convert`:
+Automatically convert Jupyter notebooks and Python scripts to marimo notebooks with `marimo convert`:
```bash
+# From Jupyter notebook
marimo convert your_notebook.ipynb -o your_notebook.py
+
+# From Python script or jupytext py:percent format
+marimo convert your_script.py -o your_notebook.py
```
Then open the notebook with `marimo edit your_notebook.py`
diff --git a/docs/guides/coming_from/jupyter.md b/docs/guides/coming_from/jupyter.md
index db9b9d2b9f..7b285234a1 100644
--- a/docs/guides/coming_from/jupyter.md
+++ b/docs/guides/coming_from/jupyter.md
@@ -145,6 +145,24 @@ Convert Jupyter notebooks to marimo notebooks at the command-line:
marimo convert your_notebook.ipynb -o your_notebook.py
```
+### Converting Python scripts to marimo notebooks
+
+marimo can also convert regular Python scripts to marimo notebooks:
+
+```bash
+marimo convert your_script.py -o your_notebook.py
+```
+
+This supports:
+- **py:percent format**: If your script uses `# %%` cell markers, marimo will convert it to a multi-cell notebook (requires jupytext)
+- **Regular Python scripts**: Scripts without cell markers are converted to a single-cell notebook
+
+For py:percent conversion with uv:
+
+```bash
+uvx --with=jupytext marimo convert your_script.py -o your_notebook.py
+```
+
### Exporting marimo notebooks to Jupyter notebooks
Export to an `ipynb` file with
diff --git a/docs/guides/coming_from/jupytext.md b/docs/guides/coming_from/jupytext.md
index ba26d3398d..aa0402f26a 100644
--- a/docs/guides/coming_from/jupytext.md
+++ b/docs/guides/coming_from/jupytext.md
@@ -25,12 +25,17 @@ on IPython/Jupyter. Here's a comparison to help you transition smoothly.
| `jupytext --to py notebook.ipynb` | `marimo convert notebook.ipynb > notebook.py` |
!!! tip "From py:percent notebooks to marimo notebooks"
- If you have a Python file encoded in the [py:percent](https://jupytext.readthedocs.io/en/latest/#text-notebooks)
- format, you can convert it to a marimo notebook in two steps:
+ marimo can directly convert Python files in the [py:percent](https://jupytext.readthedocs.io/en/latest/#text-notebooks)
+ format (requires jupytext):
```
- jupytext --to notebook.ipynb percent_notebook.py
- marimo convert notebook.ipynb > marimo_notebook.py
+ marimo convert percent_notebook.py -o marimo_notebook.py
+ ```
+
+ If using uv:
+
+ ```
+ uvx --with=jupytext marimo convert percent_notebook.py -o marimo_notebook.py
```
### To `.ipynb`