A lightweight Command Line Interface (CLI) tool for Linux/Ubuntu to convert Jupyter Notebook files (.ipynb) into plain text files (.txt). The tool extracts only the source code and markdown content cell by cell, intentionally ignoring cell outputs.
This tool can be executed using either the ipynb2txt or notebook2txt commands.
- Zero dependencies: Built using strictly Python standard libraries.
- Clean extraction: Ignores execution outputs and metadata, keeping only the actual code and markdown.
- Dual command access: Available system-wide as both
ipynb2txtandnotebook2txt. - Custom output routing: Generates a text file with the same name automatically, or allows specifying a custom output path.
You can install this tool system-wide by cloning the repository and copying the executable to your local binaries directory.
- Clone the repository
git clone https://github.com/rallm/ipynb2txt.git
cd ipynb2txt- Make the script executable:
chmod +x ipynb2txt- Copy the script to your system binaries directory using
cp:
sudo cp ipynb2txt /usr/local/bin/ipynb2txt- Create a symbolic link to make the tool available as
notebook2txtas well (optional):
sudo ln -s /usr/local/bin/ipynb2txt /usr/local/bin/notebook2txtYou can use either ipynb2txt or notebook2txt. The behavior is identical.
Converts the notebook and creates a text file with the same name in the current directory:
ipynb2txt my_notebook.ipynb(Produces: my_notebook.txt)
Use the -o or --output flag to specify an exact destination and file name:
notebook2txt my_notebook.ipynb -o /path/to/destination/custom_name.txtTo view the help manual and available arguments:
ipynb2txt --helpThis project is licensed under the MIT License.