Skip to main content

Slack Cleaner2 is an improved slack cleaner version using a python first approach

Project description


License: MIT Github Actions PyPi Read the Docs

Bulk delete messages and files on Slack.


Install from PyPi:

pip install slack-cleaner2

latest version

pip install -e git+


In contrast to the original version ( this version is a focusing on pure python package that allows for easy scripting instead of a vast amount of different command line arguments.

basic usage

from slack_cleaner2 import *

s = SlackCleaner('SECRET TOKEN')
# list of users
# list of all kind of channels

# delete all messages in -bots channels
for msg in s.msgs(filter(match('.*-bots'), s.conversations)):

for msg in s.c.general.msgs():


You will need to generate a Slack legacy user token to use slack-cleaner. You can generate a token here:

The token should start with xoxp and not like bot tokens with xoxb.

Permission Scopes needed

The permissions to grant depend on what you are going to use the script for. Grant the permissions below depending on your use.

Beyond granting permissions, if you wish to use this script to delete messages or files posted by others, you will need to be an Owner or Admin of the workspace.

Deleting messages from public channels

  • channels:history
  • channels:read
  • chat:write:user
  • users:read

Deleting messages from private channels

  • groups:history
  • groups:read
  • chat:write:user
  • users:read

Deleting messages from 1:1 IMs

  • im:history
  • im:read
  • chat:write:user
  • users:read

Deleting messages from multi-person IMs

  • mpim:history
  • mpim:read
  • chat:write:user
  • users:read

Deleting files

  • files:read
  • files:write:user
  • users:read

Configuring app

The cleaner needs you to give Slack's API permission to let it run the operations it needs. You grant these by registering it as an app in the workspace you want to use it in.

You can grant these permissions to the app by:

  1. going to Your Apps
  2. select 'Create New App', fill out an App Name (eg 'Slack Cleaner') and select the Slack workspace you want to use it in
  3. select 'OAuth & Permissions' in the sidebar
  4. scroll down to Scopes and select all scopes you need
  5. select 'Save changes'
  6. select 'Install App to Workspace'
  7. review the permissions and press 'Authorize'
  8. copy the 'OAuth Access Token' shown, and use this token as the --token argument to the script


To all the people who can only afford a free plan. :cry:



python clean sdist bdist_wheel
twine upload dist/*

change version in slack_cleaner2/

Project details

Download files

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

Files for slack-cleaner2, version 2.0.1
Filename, size File type Python version Upload date Hashes
Filename, size slack_cleaner2-2.0.1-py2.py3-none-any.whl (15.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size slack_cleaner2-2.0.1.tar.gz (19.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page