NBSTRIPOUT(1)
β¨ NAME β¨
nbstripout β strip output from Jupyter and IPython notebooks π
π¦ DESCRIPTION π¦
okay bestie, listen, this is the whole shape of the command, the synopsis, the vibe check:
usage: nbstripout [-h] [--dry-run | --install | --uninstall |
--is-installed |
--status | --version] [--verify] [--keep-count] [--keep-output]
[--keep-id] [--extra-keys EXTRA_KEYS] [--keep-metadata-keys
KEEP_METADATA_KEYS] [--drop-empty-cells] [--drop-tagged-cells
DROP_TAGGED_CELLS] [--strip-init-cells] [--attributes FILEPATH]
[--global | --system | --python PATH] [--force] [--max-size SIZE]
[--mode {jupyter,zeppelin}] [--textconv] [files ...]
πΈ POSITIONAL ARGUMENTS πΈ
filesβ the files you want the output stripped out of, periodt
π OPTIONS π
-h,--helpβ shows you this help message and then dips out--dry-runβ just tells you which notebooks would have been stripped, no touching anything, lowkey respectful--installβ installs nbstripout in the current repo (sets up the git filter and the attributes, the whole glow-up)--uninstallβ removes nbstripout from the current repo (takes the git filter and attributes back out)--is-installedβ checks whether nbstripout is installed in the current repository, yes or no bestie--statusβ prints the status of the nbstripout installation in the current repository, plus a configuration summary of the filter and attributes if it is installed--versionβ prints the version--verifyβ returns a non-zero exit code if any files were changed, and it implies--dry-run--keep-countβ do NOT strip the execution count/prompt number--keep-outputβ do NOT strip the output--keep-idβ keeps the randomly generated cell ids, which will be different after each execution (iykyk)--extra-keys EXTRA_KEYSβ space separated list of extra keys to strip from metadata, e.g.metadata.foo cell.metadata.bar--keep-metadata-keys KEEP_METADATA_KEYSβ space separated list of metadata keys to keep, e.g.metadata.foo cell.metadata.bar--drop-empty-cellsβ removes cells wheresourceis empty or contains only whitepace--drop-tagged-cells DROP_TAGGED_CELLSβ space separated list of cell-tags that remove an entire cell--strip-init-cellsβ removes cells withinit_cell: truemetadata (default: False)--attributes FILEPATHβ attributes file to add the filter to (in combination with--install/--uninstall), defaults to.git/info/attributes--globalβ use global git config (default is local config)--systemβ use system git config (default is local config)--python PATHβ path to the python executable to use when--install'ing (default is deduced fromsys.executable)--force,-fβ strip output also from files with non ipynb extension--max-size SIZEβ keep outputs smaller than SIZE--mode,-m {jupyter,zeppelin}β specify mode between[jupyter (default) | zeppelin](to be used in combination with-f)--textconv,-tβ prints stripped files to STDOUT
π STRIP OUTPUT FROM JUPYTER AND IPYTHON NOTEBOOKS π
Opens a notebook, strips its output, and writes the outputless version to the original file. β¨
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS. no cap.
This does mostly the same thing as the Clear All Output command in the notebook UI. iconic behaviour honestly.
π USAGE π
Strip output from IPython / Jupyter / Zeppelin notebook (modifies the file in-place): ::
nbstripout <file.ipynb>
nbstripout <file.zpln>
By default, nbstripout will only modify files ending in .ipynb or .zpln, to process other files us the -f flag to force the application.
nbstripout -f <file.ipynb.bak>
For using Zeppelin mode while processing files with other extensions use:
nbstripout -m zeppelin -f <file.ext>
Use as part of a shell pipeline: ::
cat FILE.ipynb | nbstripout > OUT.ipynb
cat FILE.zpln | nbstripout -m zeppelin > OUT.zpln
Set up the git filter and attributes as described in the manual installation instructions below: ::
nbstripout --install
Set up the git filter using .gitattributes ::
nbstripout --install --attributes .gitattributes
Set up the git filter in your global ~/.gitconfig ::
nbstripout --install --global
Set up the git filter in your system-wide $(prefix)/etc/gitconfig (most installations will require you to sudo) ::
[sudo] nbstripout --install --system
Remove the git filter and attributes: ::
nbstripout --uninstall
Remove the git filter from your global ~/.gitconfig and attributes ::
nbstripout --uninstall --global
Remove the git filter from your system-wide $(prefix)/etc/gitconfig and attributes ::
nbstripout --uninstall --system
Remove the git filter and attributes from .gitattributes: ::
nbstripout --uninstall --attributes .gitattributes
Check if nbstripout is installed in the current repository (exits with code 0 if installed, 1 otherwise): ::
nbstripout --is-installed
Print status of nbstripout installation in the current repository and configuration summary of filter and attributes if installed (exits with code 0 if installed, 1 otherwise): ::
nbstripout --status
Do a dry run and only list which files would have been stripped: ::
nbstripout --dry-run FILE.ipynb [FILE2.ipynb ...]
Print the version: ::
nbstripout --version
Show this help page: ::
nbstripout --help
π MANUAL FILTER INSTALLATION π
Set up a git filter using nbstripout as follows: ::
git config filter.nbstripout.clean '/path/to/nbstripout'
git config filter.nbstripout.smudge cat
Create a file .gitattributes or .git/info/attributes with: ::
*.ipynb filter=nbstripout
Apply the filter for git diff of *.ipynb files: ::
git config diff.ipynb.textconv '/path/to/nbstripout -t'
In file .gitattributes or .git/info/attributes add: ::
*.ipynb diff=ipynb
okay that's literally the whole page, you ate it, go forth and strip some outputs π«Ά This one's from nbstripout 0.8.1, dated July 2025 β mwah, bestie, stan ππβ¨
π¦ where this page comes from
- ubuntu resolute: nbstripout 0.9.0-1
- ubuntu stonking: nbstripout 0.9.1-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms