nbstripout removes notebook outputs and selected metadata while keeping cells. It is meant as a Git filter or hook so commits stay small and diff-friendly.
Overview
nbstripout reads Jupyter, IPython, or Zeppelin notebook files and strips execution output plus configurable metadata, then writes the cleaned notebook back to disk or stdout. Behavior is similar to clearing all outputs in the notebook UI, but filtering happens when Git records versions so local outputs can remain on disk.
The command supports in-place editing, pipelines, dry-run and verify modes, and recursive processing. Optional flags drop empty cells, tagged cells, init cells, or specific output types while preserving counts, cell IDs, or outputs marked with metadata or tags.
Install via pip or conda, then register with `nbstripout --install` as a required Git filter at repository, global, or system scope. Attributes can live in `.gitattributes` so teams share rules. The tool can rewrite history with git-filter-repo scripts for existing repositories.
Global and system installs apply the filter to all `.ipynb` files across machines. Extra metadata keys to strip or keep can be set through Git config or CLI flags.
Key features
- Strip Jupyter and Zeppelin outputs
- Git filter and diff driver setup
- Keep output locally, omit from commits
- Drop empty or tagged cells
- Configurable metadata stripping
- Dry-run and verify modes
- Global or per-repo install
- Pipeline and stdin or stdout use
Use cases
- Cleaner Git diffs for notebooks
- Smaller notebook commits without images
- Team-wide output stripping policy
- CI verification that outputs are stripped
- Retroactive history cleanup for ipynb