Clean Jupyter notebooks for LLMs and lightweight sharing.
Project description
ipynbCleaner
ipynbcleaner is a small Python utility for reducing the noise in Jupyter Notebook files before sharing them with other developers, storing them in version control, or sending them to LLMs.
It removes notebook-level metadata by default, strips cell metadata, clears execution counters, and keeps only the last output from code cells unless you choose to drop outputs entirely.
Why this exists
Notebook files often carry a lot of extra data that is useful for interactive execution but not useful when the goal is to review code or feed the notebook to an LLM. That extra payload makes the file heavier and burns context budget quickly.
This project keeps the notebook structure intact while trimming the parts that usually add noise.
Features
- Removes notebook-level metadata by default.
- Removes cell metadata, cell IDs, and attachments by default.
- Keeps code and markdown source intact.
- Keeps only the last code cell output by default.
- Can drop all outputs when needed.
- Exposes both a Python API and a CLI.
Installation
From source:
pip install .
For development:
pip install -e .
Usage
CLI
ipynbcleaner notebook.ipynb
ipynbcleaner notebook.ipynb notebook_clean.ipynb
ipynbcleaner notebook.ipynb --drop-outputs
Available options:
--drop-outputsremoves every output from code cells.--keep-execution-countpreserves execution counts.--keep-root-metadatapreserves notebook-level metadata.--keep-cell-metadatapreserves cell metadata.--keep-cell-idspreserves Jupyter cell IDs.--keep-attachmentspreserves markdown attachments.
Python API
from ipynbcleaner import CleanOptions, clean_notebook_file
clean_notebook_file("notebook.ipynb", options=CleanOptions(keep_last_output=True))
Project status
This repository is now structured as a distributable Python package with a console script entry point and basic regression tests, so it is ready for iteration toward a PyPI release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipynbcleaner-0.1.0.tar.gz.
File metadata
- Download URL: ipynbcleaner-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d16bbe01491668311ebef9538059e3d6cd1af14b9513569300ba053c010b76b
|
|
| MD5 |
28c51e037ffe044a2ce17faebf49c17a
|
|
| BLAKE2b-256 |
d30af1e5bb662a4ad7568cd7e1586c3cbf9b6cc1d943022601d725bd4125c7e1
|
Provenance
The following attestation bundles were made for ipynbcleaner-0.1.0.tar.gz:
Publisher:
ci.yml on DanielDPereira/ipynbCleaner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipynbcleaner-0.1.0.tar.gz -
Subject digest:
0d16bbe01491668311ebef9538059e3d6cd1af14b9513569300ba053c010b76b - Sigstore transparency entry: 2087288872
- Sigstore integration time:
-
Permalink:
DanielDPereira/ipynbCleaner@c9cf9599bcc656148c8bfd929716a4f36a333632 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DanielDPereira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@c9cf9599bcc656148c8bfd929716a4f36a333632 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipynbcleaner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipynbcleaner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66a80112be038e77210d44ad2bd17b71322c3692d7fa1daef7bdf8dec548d52e
|
|
| MD5 |
4f2843eb23595449d009980e75bd3008
|
|
| BLAKE2b-256 |
9151a4bb50bbf9e04adeb3b53bd09fdc4d2b280ff3c5511411e40e28567edac7
|
Provenance
The following attestation bundles were made for ipynbcleaner-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on DanielDPereira/ipynbCleaner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipynbcleaner-0.1.0-py3-none-any.whl -
Subject digest:
66a80112be038e77210d44ad2bd17b71322c3692d7fa1daef7bdf8dec548d52e - Sigstore transparency entry: 2087288975
- Sigstore integration time:
-
Permalink:
DanielDPereira/ipynbCleaner@c9cf9599bcc656148c8bfd929716a4f36a333632 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DanielDPereira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@c9cf9599bcc656148c8bfd929716a4f36a333632 -
Trigger Event:
push
-
Statement type: