Twitter is one of the most popular social media platforms on the planet, garnering over 336 million users as of the writing of this article.
Perhaps it's been a few years and you have managed to accumulate tens of thousands of tweets, some of which you'd like to get rid of as you probably said some stupid or embarrassing things when you were underage or something. So, what can you do?

Twitter does not offer a very good or easy way to clean up your account. External sites offering services to do so usually only let you have a delete all option, but for a lot of people (especially artists) this is not an ideal solution.
There are paid services that allow you to manually delete tweets by specific dates, but of course paying for a service (especially one that will allow access to your account) is not ideal either.

What is the solution then? Manually deleting such a large amount of tweets is obviously not an option.
It's not easily available online, but I figured out myself how to achieve this a while back so I thought I would share this knowledge with others.

What do I need?

The very first thing you must do is to download your twitter archive. This option is requestable in your settings and after a short while twitter will email you a download link.



I found a very interesting issue when I tried to request mine, though. Older twitter accounts sometimes encounter a glitch where the email address input is not working correctly and they cannot recieve emails from twitter (thanks twitter staff!). It will not allow you to change the email. You cannot contact customer support as they will email you a response which of course you will never recieve. You also cannot contact them about it from another account as they'll simply handwave you away and tell you that they will only engage with the account owner about account issues. Twitter do not have a public email or any external contact information outside of their account centered helpdesk, I looked high and low. So this is a pretty huge roadblock.

For some weird reason it did allow me to change the email in the twitter phone app, so what I did was change it to another email address, then change it back to my main email and I was finally able to request my archive. If you encounter this issue, this is the solution!

The next thing you need to do is to apply as a twitter developer as it will give you access to your API key. This process should be pretty quickly handled, I think my application was approved in about 30 minutes. This step is necessary.
The tweets.csv file is the one we'll be needing.

After that, you need to use python as we'll be running a python script to do this. Python is available for free download on a multitude of platforms. I personally did this on a mac.

The Script

Once you have all that, you need to install tweepy. You can do this by installing it in the terminal via;


If this type of thing is confusing or you aren't used to code, then please download Python's Anaconda bundle to get started. I had 0 python experience prior to this and yet still managed, it's a lot more intimidating than it seems! This is what I downloaded and I used the (Jupyter) QtConsole application for this entire thing.

After this, you need to import tweepy to our console. You do it like so;



Type it and then press shift + enter to send the command. After that, you'll need to grab your API keys and fill them in appropriately here (in the commas).
Never share these keys with anyone as it will allow people access to your account!



The next part of the code is it's functions, and at the very end you need to specify the location of your tweets.csv document I mentioned earlier, as this is what it will call to reference when it's deleting everything.



Your link should look a little something like "tweets = read_csv('/Users/Anon/Desktop/twitterarchive/tweets.csv')".

This is the entire script you'll use to authorise the console into being able to edit and delete tweets while referencing your twitter archive for commands.



When this is all done, you'll get this message "Authenticated as:(twitter username)". You're in.
Once this is all set up, you're ready to start deleting your tweets (hooray!!)

I personally found the best way to do this was to delete by month. Here is the code to do that:


Obviously, you can ammend the year and month to whatever it is you want.

To search by term, hashtag or word, you can use this command:



To confirm how many entries you have, next you can enter this command:



Now it's the very last thing! To start the deleting process, just enter the code below.


And that's it! All you do now is leave the script run it's course.



It'll take some time for it to finish, so leave it overnight and let it do it's thing. But that's the entire script and steps involved!
I hope this was helpful, I personally found this quite difficult because I didn't have any experience with python at all and I ended up sort of using a mishmash of about 4 different solutions online because I couldn't get any specific one to work (as I was sort of running things and praying they'd work). If you're python uneducated like me, I hope you found this easy to read and follow.

I heavily based this on this site's code, so credit to it's author for most of this! https://pushpullfork.com/i-deleted-tweets/