Jupytext

Have you always wished Jupyter notebooks were plain text?

Jupytext saves your notebooks as .py or .md files — easy to edit in any IDE, friendly to version control, and trivial for AI assistants to read and refactor.

$ pip install jupytext
git diff — notebook.py
# %% [markdown]
# # Sales report
- df = df.dropna()
+ df = df.dropna().reset_index(drop=True)
+ df["margin"] = df.revenue - df.cost

# %%
df.groupby("region").margin.sum().plot.bar()

The same notebook — as a diff your team can actually read.

The challenge

Keeps the focus on what you write

A one-line code change comes with execution counts, base64 image outputs, and cell metadata in the diff. Jupytext gives you a text file that contains only the source — the part you actually write and review.

A change to notebook.ipynb
-   "execution_count": 12,
-   "outputs": [{"data": {"image/png":
-   "iVBORw0KGgoAAAANSUhEUg..."}}],
-   "metadata": {"id": "a1b2c3"},
-   "source": ["df = df.dropna()"]
+   "execution_count": 47,
+   "outputs": [{"data": {"image/png":
+   "iVBORw0KGgoAAAANSUhEUg..."}}],
The same change to notebook.py
  # %%
- df = df.dropna()
+ df = df.dropna().reset_index(drop=True)




Why Jupytext

One small tool, a lot less friction

Keep the interactive notebook you love. Gain everything that plain text gives you.

🔍

Clean, reviewable diffs

No more unreadable JSON blobs. Text notebooks produce line-by-line diffs you can actually review in a pull request.

✏️

Edit in any IDE

Open your notebooks in VS Code, PyCharm, Spyder, vim — anywhere. No JSON, no merge nightmares, full editor superpowers.

🧹

Refactor, lint & format

Run black, ruff, isort or flake8 over your notebooks like ordinary scripts. Pipe them through any tool from the CLI.

♻️

Reuse your code

A text notebook is a valid module. Import functions from it, or run it as a script — no copy-paste between files.

🔗

Round-trip safe

Pair the text file with an .ipynb and keep your rich outputs. Inputs come from the text, outputs from the notebook.

🌐

Many languages & formats

Python, R, Julia and more — as percent scripts, Markdown, MyST, Quarto or Pandoc. Pick what fits each notebook.

New superpower

Notebooks your AI assistant can actually read

Coding assistants like Claude, GitHub Copilot and Cursor work in plain text. Pair your notebooks with Jupytext and they can read, edit and refactor them directly — no JSON wrangling, no broken outputs, no special tooling.

  • Ask an agent to refactor a cell — it edits the .py file, you reload in Jupyter.
  • Reviews and AI suggestions land as clean, minimal diffs.
  • Outputs stay safe in the paired .ipynb while the text gets edited.
assistant editing analysis.py
# %% [markdown]
# ### Refactor: vectorize the loop 🤖

- totals = []
- for r in regions:
-     totals.append(df[df.region==r].sales.sum())
+ totals = df.groupby("region").sales.sum()
How it works

Paired notebooks: the best of both worlds

Keep a rich .ipynb (with outputs) alongside a clean .py or .md. Jupytext keeps them in sync — commit only the text file.

Pair

Tell Jupytext to pair your notebook with a text format — once, or for the whole project via jupytext.toml.

Edit anywhere

Edit the .py in your IDE or with an AI assistant, or run the notebook in Jupyter. Reload to pick up changes.

Sync & commit

On save (or with jupytext --sync) both files update. Version-control the text; outputs stay in the .ipynb.

Quickstart

Five commands you'll actually use

Turn a notebook into a text file (or back again).
jupytext --to py:percent notebook.ipynb
Formats

Same notebook, your choice of text

The cell below is the same content in each format. Pick whichever suits the notebook.

py:percent
# %% [markdown]
# # Analysis
# A quick look at the data.

# %%
import pandas as pd
df = pd.read_csv("data.csv")
df.describe()

Best for code-heavy notebooks — cell markers understood by VS Code, PyCharm, Spyder & Hydrogen.

Integrations

Fits the tools you already use

7k+
GitHub stars
3M+
Downloads / month
30+
Languages supported
100+
Contributors
MIT
Open source

Give your notebooks a clean text life

Install Jupytext, pair a notebook, and enjoy reviewable diffs, IDE editing and AI-ready files.

$ conda install jupytext -c conda-forge