How to mass unfollow on Twitter

If you’re wanting to reduce your following count and don’t trust all those Chrome extensions and scripts, see below. There seems to be a limit per day which varies between accounts, however run and see.

Mr Musk and team have also thought of many ways to prevent this, so it took some time to figure out what will work. Thankfully I had some AI help.

How to unfollow all:

  • Log in to your Twitter account in your web browser.
  • Go to your “Following” list by clicking on the “Following” link on your profile page or by visiting
  • Press F12 or Ctrl + Shift + J (Windows/Linux) or Cmd + Opt + J (Mac) to open the Developer Tools.
  • Click on the “Console” tab.
  • Copy and paste the following JavaScript code snippet into the console and press Enter:
const unfollowAll = async () => {
  const unfollowButtons = Array.from(document.querySelectorAll('[data-testid="unfollow"]'));
  for (const button of unfollowButtons) {;
    await new Promise(resolve => setTimeout(resolve, 1000));
  window.scrollTo(0, document.body.scrollHeight);
  setTimeout(unfollowAll, 2000);

Hit Enter, and this should run through a loop. Each loop it will unfollow all on screen, pause for 2 seconds then execute again:

This method appeared to be working but sadly doesn’t. I then expanded to be more “human like”. This again sadly failed, but we got further.

On the next job, we simulated the Enter button, so that it would truly unfollow, however this failed:

let removedCount = 0;
const randomDelay = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
const randomPauseAfter = () => Math.floor(Math.random() * 4) + 3;
const sendEnterKeyPress = (element) => {
  const event = new KeyboardEvent('keydown', {
    bubbles: true,
    cancelable: true,
    key: 'Enter',
    keyCode: 13,
    which: 13,
const unfollowAll = async () => {
  const unfollowButtons = Array.from(document.querySelectorAll('[data-testid$="-unfollow"]'));
  let pauseAfter = randomPauseAfter();
  let currentCount = 0;
  for (const button of unfollowButtons) {
    if (removedCount >= 500) {
      console.log("Stopped after removing 500 users.");
    // Click the "Following" button to open the confirmation dialog;
    await new Promise(resolve => setTimeout(resolve, randomDelay(2000, 3500)));
    // Send an 'Enter' keypress event on the "Unfollow" button in the confirmation dialog
    const confirmButton = document.querySelector('div[role="dialog"] div[data-testid="confirmationSheetConfirm"]');
    if (confirmButton) {
      console.log(`Removed count: ${removedCount}`);
    if (currentCount >= pauseAfter) {
      await new Promise(resolve => setTimeout(resolve, randomDelay(15000, 30000)));
      pauseAfter = randomPauseAfter();
      currentCount = 0;
    } else {
      await new Promise(resolve => setTimeout(resolve, randomDelay(5000, 10000)));
  if (removedCount < 500) {
  } else {
    console.log("Finished removing 500 users.");

Although this appears to work, Twitter will block after around 17-20 attempts. Instead I found the most effective method was to go back to basics. Good old keyboard smashing!

This code will let you unfollow 1000 followings (Daily limit) in no time. All you need to do is hit Enter + down. Every time you press the down button on your keyboard, it will automatically go to the next and unfollow. Because they added the confirmation to slow things down, you will need to hit enter on your keyboard.

Smash: Down and Enter:

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const waitForArrowDown = () => {
  return new Promise((resolve) => {
    const listener = (event) => {
      if (event.key === "ArrowDown") {
        window.removeEventListener("keydown", listener);
    window.addEventListener("keydown", listener);
const scrollToBottom = () => {
  window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });
const unfollowAll = async () => {
  while (true) {
    const unfollowButtons = Array.from(document.querySelectorAll('[data-testid$="-unfollow"]'));
    if (unfollowButtons.length === 0) {
      console.log("No unfollow buttons found. Scrolling down...");
      await delay(3000);
    for (const button of unfollowButtons) {
      console.log("Clicking unfollow button...");;
      console.log("Waiting for you to press ArrowDown on the confirmation prompt...");
      await waitForArrowDown();
      console.log("Unfollow confirmed. Moving to the next button...");


Create a website or blog at

%d bloggers like this: