How to Delete Multiple Instagram Comments at Once Using JavaScript
Introduction
Instagram doesn’t provide a native option to delete multiple comments at once. If you have hundreds of spam or unwanted comments, doing it manually is a nightmare.
In this article, I’ll show you a simple JavaScript script that automates the process directly from your browser.
Why This Script?
- Instagram only allows manual comment deletion.
- This script simulates clicks on Instagram’s web interface.
- You can delete comments in batches (e.g., 20 at a time).
Before You Start
You need to use Instagram Web from a computer. Here’s what to do:
- Open your browser (Chrome, Edge, Firefox).
- Go to Instagram Web and log in.
- Navigate to Your Activity → Comments (this is where Instagram lists all your comments).
- Open the Developer Tools Console:
- Press F12 or Ctrl + Shift + I (Windows) / Cmd + Option + I (Mac).
- Click on the Console tab.
The Script
Paste this script into the console and press Enter:
(async () => {
function simulateClick(el) {
const evt = new MouseEvent("click", { bubbles: true, cancelable: true, view: window });
el.dispatchEvent(evt);
}
async function deleteBatch(batchSize = 20) {
const selectBtn = Array.from(document.querySelectorAll("span"))
.find(el => el.textContent.trim() === "Select");
if (selectBtn) simulateClick(selectBtn.parentElement);
await new Promise(r => setTimeout(r, 1500));
const checkboxes = Array.from(document.querySelectorAll('[data-testid="bulk_action_checkbox"] [role="button"]'));
if (checkboxes.length === 0) return false;
const batch = checkboxes.slice(0, batchSize);
for (let i = 0; i < batch.length; i++) {
simulateClick(batch[i]);
await new Promise(r => setTimeout(r, 300));
}
const deleteBtn = await new Promise(resolve => {
const interval = setInterval(() => {
const btn = document.querySelector('[aria-label="Delete"]');
if (btn && !btn.hasAttribute('disabled')) {
clearInterval(interval);
resolve(btn);
}
}, 500);
});
simulateClick(deleteBtn);
await new Promise(r => setTimeout(r, 1500));
const confirmBtn = Array.from(document.querySelectorAll('span'))
.find(el => el.textContent.trim() === 'Delete');
if (confirmBtn) simulateClick(confirmBtn.parentElement);
await new Promise(r => setTimeout(r, 3000));
return true;
}
await deleteBatch(20);
})();
How It Works
Activates the selection mode.
Selects up to 20 comments (you can change this number).
Clicks the Delete button when available.
Confirms the deletion in the popup.
Customizations
batchSize: Change the number of comments to delete per cycle.
Delays: If Instagram is slow, increase the setTimeout values.
Warnings
Works only on Instagram Web.
Don’t abuse it: Instagram may temporarily block actions if they’re too fast.
Use only on accounts you own.
Top comments (0)