Text as Notebook
Open any Python (.py) or Markdown (.md) file as a native VS Code notebook. In Python, each # %% marker starts a new cell. In Markdown, language-tagged code fences create code cells (```python [code]```). The file stays plain text on disk; no paired .ipynb file is created.
This extension uses the same plain-text notebook formats as Jupytext. It does not pair or synchronize text files and .ipynb files: conversion is explicit, and supported text files can be opened, edited, and run as notebooks.
Usage
- Install the extension and the Jupyter extension.
- In the Explorer, right-click a
.py, .md, or .markdown file and select Text as Notebook → Open as Notebook. You can also run Open as Notebook from the Command Palette.
- Select a kernel, edit and run cells, then save. The original text file is updated.
Opening a file normally still opens it as text. This extension does not change the default editor for Python files.
Notebook outputs are temporary because text files do not store them. Use Save as .ipynb with Outputs to create an .ipynb snapshot when you need to keep outputs.
Commands
All Explorer commands are under Text as Notebook.
| Command |
Description |
| Open as Notebook |
Open a .py, .md, or .markdown file in the notebook editor. |
| Open as Text |
Return an open text-backed notebook to the text editor. |
| New Percent Notebook |
Create and open a new .py notebook with a # %% cell. |
| New Markdown Notebook |
Create and open a new Markdown notebook. |
| Save as .ipynb with Outputs |
Save the current notebook, including outputs, as an .ipynb file. |
| Convert to .ipynb |
Create an .ipynb copy of a text notebook. |
| Convert to .py (# %% script) |
Create a percent-format Python copy of an .ipynb notebook. |
| Convert to .md |
Create a Markdown copy of an .ipynb notebook. |
| Convert Cell Markers to # %% |
Convert supported foreign Python cell markers to # %%. |
Conversions are one-way: the source file is unchanged, and the two files are not kept in sync. Converting an .ipynb to text does not keep its outputs.
Requirements
Verified compatible with jupytext 1.19.4
- Python notebooks in Jupytext's
py:percent format (the # %% plain-text format).
- Markdown notebooks in Jupytext's
md format.
- Not supported: other Jupytext formats, including
py:light, MyST Markdown, R Markdown, and Quarto; other notebook text formats such as .sql are also unsupported.
- Convert Cell Markers to # %% can convert recognized Python marker conventions—including Jupytext
py:light, Databricks, and legacy Jupyter markers—to py:percent.
Limitations
- The desktop VS Code app is supported. Browser-only
vscode.dev and github.dev are not supported.
- macOS has CI coverage but has not been manually tested.
Contributing
See CONTRIBUTING.md.
Credits
- jupytext for the supported text formats.
- The VS Code Jupyter extension for notebook editing and kernels.