Mass Delete Tweets (free & no 3rd-party apps)

In this post I want to explain how you can mass-delete old tweets without the need to use a 3rd-party service that probably also want your money or scripts that require you to create an application on the Twitter developer portal. You will just make use of Firefox, Tweetdeck, some shell scripts and two command line tools.

To follow this tutorial you need the following prerequisites:

  • An account at Twitter with tweets you want to delete (otherwise this tutorial is totally useless for you)
  • Firefox
  • Basic knowledge of how to use a terminal
  • curl, jq and bash installed on your system (I will use a standard Linux distribution with a zsh-shell, so if you are using Windows or Mac, or another shell, commands can slightly differ)

Disclaimer

I’m not responsible for any damage caused by you following this tutorial! You have to understand what commands you execute and what they do and if you don’t understand them, better don’t do them! If you are breaking any of Twitter’s Terms of Service, I’m not responsible for that!


Background story

Why am I writing this tutorial? Because a few days ago, I noticed that I have way to many tweets on my Twitter account. Many never got any attention and some where just old and outdated. I wanted an easy way to delete some but not all tweets and I didn’t want to pay anything for the deletion of my tweets. And my time was also too valuable to me to spend days clicking manually on every tweet I want to delete.

So I found a way to do that using a few shell commands and scripts. And now I want to share my findings with other people, probably in the same situation. #sharingiscaring


Back in 2011 Twitter bought TweetDeck, a third party (no obviously first party) Twitter app (or website) with a different UI approach. With TweetDeck you have multiple rows which you can customize. You can also use multiple accounts at the same time, schedule tweets etc.

To start, open Firefox and login to TweetDeck. Click on your profile, on “tweets” and right-click and select “Inspect element” to open the developer tools. Now switch to the “Network” tab.

In your tweets list, find one tweet you want to delete. But before you delete it, clear the network log. Now you can delete your tweet and pause the network log.

Search for “destroy” in the network requests list and you should see a “POST” request with a number followed by .json. That is the request that deleted your tweet. Right-click on it and select “Copy as cURL-request”. Firefox creates a curl command containing all headers and parameters it needs to do destroy other tweets too. TweetDeck seems to use the official Twitter API. Copying the request from TweetDeck saves you creating a new app in the developer portal, which some scripts or tools require you to do. That can be time consuming because Twitter is very restrictive and require manual approval of every application.

Open an editor and paste the content in there. To make it a script, modify it to look like this:

#!/usr/bin/env bash
curl "https://api.twitter.com/1.1/statuses/destroy/$1.json"

You have to add the first line and replace the number (the unique id of the tweet) with $1, so that script can later be called with any tweet id as first parameter and it will delete this tweet. Save the file as deletetweet.sh and make it executable (you can do this by calling chmod +x followed by the file name).

Create another executable file named deletealltweets.sh in the same location and paste in the following content:

#!/usr/bin/env bash
while read in; do ./deletetweet.sh "$in"; done < tweetstodelete.txt

This script reads every line from a text file tweetstodelete.txt and executes the first script for every line of it. The text file tweetstodelete.txt will later contain all the unique ids of the tweets you want to delete.

Now you have everything needed to mass delete or better say mass destroy tweets. Now you need the ids…


To get a list of ids, first you need to export your Twitter data. How you can do this is described here.

After exporting your data you should have a zip archive and inside of it there should be a tweet.js file. Copy that file, rename it to tweet.json and remove window.YTD.tweet.part0 = from the beginning of the file. Now you have a JSON file with all your tweets data (depending on the amount of tweets that file can be quite big) and you can filter it and extract the ids using a tool called jq.

To get all tweet ids of tweets that have no likes, no retweets and aren’t replies, this is the command you can use:

cat tweet.json | jq '.[] | select(.favorite_count == "0") | select(.retweet_count == "0") | select(has("in_reply_to_user_id_str") | not)  | .id' -r > tweetstodelete.txt

To get the ids of all your tweets, this is the command to go:

cat tweet.json | jq '.[] | .id' -r > tweetstodelete.txt

As you can see, you can use jq to filter just specific tweets. You can create custom filter rules by looking at the tweet.json file and looking at the jq manual on how to use filters and what operators are available. I’m sorry that I can’t give you more specific tips here, but I’m not very familiar with jq either. You might find answers on StackOverflow. 😅

If you finally have your file with all the ids and you are sure that you want to delete them FOREVER and PERMANENTLY, type this command to your console:

./deletealltweets.sh

… and wait until it’s finished. It will probably take some time. Your tweets are gone!

I only tested it with around 2000 tweets, so I don’t know if Twitter applies any restrictions when you try to delete many more. But if you notice many errors, you should probably cancel the operation and continue at a later point.

20 years old student who writes about everything he cares about.