Scroll to navigation

NBSTRIPOUT(1) User Commands NBSTRIPOUT(1)

NAME

nbstripout - strip output from Jupyter and IPython notebooks

DESCRIPTION

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 to strip output from

options:

show this help message and exit
Print which notebooks would have been stripped
Install nbstripout in the current repository (set up the git filter and attributes)
Uninstall nbstripout from the current repository (remove the git filter and attributes)
Check if nbstripout is installed in current repository
Print status of nbstripout installation in current repository and configuration summary if installed
Print version
Return a non-zero exit code if any files were changed, Implies --dry-run
Do not strip the execution count/prompt number
Do not strip output
Keep the randomly generated cell ids, which will be different after each execution.
Space separated list of extra keys to strip from metadata, e.g. metadata.foo cell.metadata.bar
Space separated list of metadata keys to keep, e.g. metadata.foo cell.metadata.bar
Remove cells where `source` is empty or contains only whitepace
Space separated list of cell-tags that remove an entire cell
Remove cells with `init_cell: true` metadata (default: False)
Attributes file to add the filter to (in combination with --install/--uninstall), defaults to .git/info/attributes
Use global git config (default is local config)
Use system git config (default is local config)
Path to python executable to use when --install'ing (default is deduced from `sys.executable`)
Strip output also from files with non ipynb extension
Keep outputs smaller than SIZE
Specify mode between [jupyter (default) | zeppelin] (to be used in combination with -f)
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.

This does mostly the same thing as the `Clear All Output` command in the notebook UI.

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
July 2025 nbstripout 0.8.1