A Node.js script that automatically deletes the images from your Imgur account, whether they are in albums or not.
- Automatically fetches an
access_tokenfrom yourrefresh_token. - Batch deletion with rate limit handling.
- Dry-run mode (simulation).
- Delete mode (actual deletion).
- Node.js v22+
- An Imgur account and a Client ID / Client Secret from the Imgur dashboard
- A refresh token, generated during OAuth authorization
-
Create an application
- Go to https://api.imgur.com/oauth2/addclient
- Choose "OAuth2 without callback" (or with a callback if you have a URL)
- Write down the Client ID and the Client Secret.
-
Generate a refresh token
-
Open this URL in your browser:
https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=tokenReplace
YOUR_CLIENT_IDwith your own Client ID. -
Authorize the application, then copy the
refresh_tokenvalue from the redirect URL in your browser.
-
-
Copy
.env.exampleto.envat the root of the project:cp .env.example .env
-
Open
.envand add your keys:IMGUR_CLIENT_ID="your_client_id" IMGUR_CLIENT_SECRET="your_client_secret" IMGUR_REFRESH_TOKEN="your_refresh_token"
Warning: never share your credentials in plain text.
Install the dependencies listed in package.json:
npm installShows how many images would be deleted, without deleting anything:
npm run dryActually deletes all the listed images:
npm run deleteDeletions run with limited concurrency (3 requests at a time), and each failed request is retried with exponential backoff (up to 5 retries, from 1 s to 30 s), which covers 429 Rate Limit responses.
If you keep getting blocked, wait a moment, or lower the concurrency value in src/api/deleteImages.js.
- Fork this repo
- Create a branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add a feature') - Push the branch (
git push origin feature/my-feature) - Open a pull request