NBSTRIPOUT(1)

πŸ“¦ version 0.9.1, in ubuntu resolute, ubuntu stonking

✨ 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 where source is 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 with init_cell: true metadata (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 from sys.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