Skip to main content

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-outputs removes every output from code cells.
  • --keep-execution-count preserves execution counts.
  • --keep-root-metadata preserves notebook-level metadata.
  • --keep-cell-metadata preserves cell metadata.
  • --keep-cell-ids preserves Jupyter cell IDs.
  • --keep-attachments preserves 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipynbcleaner-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipynbcleaner-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for ipynbcleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d16bbe01491668311ebef9538059e3d6cd1af14b9513569300ba053c010b76b
MD5 28c51e037ffe044a2ce17faebf49c17a
BLAKE2b-256 d30af1e5bb662a4ad7568cd7e1586c3cbf9b6cc1d943022601d725bd4125c7e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipynbcleaner-0.1.0.tar.gz:

Publisher: ci.yml on DanielDPereira/ipynbCleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ipynbcleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66a80112be038e77210d44ad2bd17b71322c3692d7fa1daef7bdf8dec548d52e
MD5 4f2843eb23595449d009980e75bd3008
BLAKE2b-256 9151a4bb50bbf9e04adeb3b53bd09fdc4d2b280ff3c5511411e40e28567edac7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipynbcleaner-0.1.0-py3-none-any.whl:

Publisher: ci.yml on DanielDPereira/ipynbCleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page